我是Angularjs的新手,我希望将整个月份日期显示为标题,当我从日期选择器中选择该特定月份日期时,应根据选择仅显示其他月份,以检查员工的出勤率
答案 0 :(得分:0)
你应该试试这个:
创建月份HTML:
<select ng-model="calculate.months" ng-change="monthCalculate(calculate.months)">
<option ng-repeat="x in monthsValue" value="{{x.value}}">{{x.name}}</option>
</select>
app.js中的
$scope.monthsValue = [
{name: "January", value: "1"},
{name: "February", value: "2"},
{name: "march", value: "3"}
];
用于动态月绑定。
允许在angularjs中打印月日:
选定月份:{{calculate.months}} <div ng-model="totalDays">
<div ng-repeat="i in range(totalDays) track by $index">
<span> {{$index + 1}} </span>
</div>
</div>
并在app.js中:
$scope.monthCalculate = function (months) {
getMonthDays = daysInMonth(months, 2016);
$scope.totalDays = getMonthDays;
};
function daysInMonth(month, year) {
return new Date(year, month, 0).getDate();
}
$scope.range = function (n) {
return new Array(n);
};
让我们试一试希望这可以帮到你。
在这里查看工作演示:
https://jsfiddle.net/randheer/atf7L4hL/
感谢
Randheer