是。 有一个名为md-date-filter
的attribut,您可以使用它来指定您希望用户选择的日期。 在下面的示例中,您正在return day === 1;
它只允许选择星期一。 您可以根据需要将其从o更改为7。
html视图文件
<md-datepicker ng-model="myDate" md-placeholder="Enter date" md-date-filter="onlyMonday">
</md-datepicker>
在控制器文件中
$scope.onlyMonday = function(date) {
var day = date.getDay();
return day === 1;
}
http://codepen.io/next1/pen/EKmdPx
Yes. There is an attribut called md-date-filter
which you can use to specify the day you want to be selected by user. In the below example as you are returing return day === 1;
It will allow to select mondays only. you can change it from o to 7 as required.
html view file
<md-datepicker ng-model="myDate" md-placeholder="Enter date" md-date-filter="onlyMonday">
</md-datepicker>
In Controller File
$scope.onlyMonday = function(date) {
var day = date.getDay();
return day === 1;
}
http://codepen.io/next1/pen/EKmdPx
请发表评论