Angular Material Date Picker 只设置一个特定的星期几可选(例如:星期一) [英] Angular Material Date Picker Set Only a Particular Day of Week Selectable (Eg: Monday)

查看:23
本文介绍了Angular Material Date Picker 只设置一个特定的星期几可选(例如:星期一)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 Angular Material Date Picker 是否有任何过滤机制,以便我可以设置只有星期一可以从 Date Picker 中选择.

I wonder is there any filtering mechanism for the Angular Material Date Picker, So that I can set only Mondays are selectable from the Date Picker.

提前致谢.

问候...

推荐答案

是的.有一个名为 md-date-filter 的属性,您可以使用它来指定用户希望选择的日期.在下面的示例中,当您返回 return day === 1; 时,它将只允许选择星期一.您可以根据需要将其从 o 更改为 7.

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 查看文件

<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

这篇关于Angular Material Date Picker 只设置一个特定的星期几可选(例如:星期一)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆