• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

角度材料日期选择器仅设置可选择的特定日期(例如:星期一)(Angular Material Date P ...

原作者: [db:作者] 来自: 网络 收藏 邀请

角度材料日期选择器仅设置可选择的特定日期(例如:星期一)(Angular Material Date Picker Set Only a Particular Day of Week Selectable (Eg: Monday))

我想知道Angular Material 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.

Thanks in Advance.

Regards...


原文:https://stackoverflow.com/questions/36198626
更新时间:2022-03-22 09:03

最满意答案

是。 有一个名为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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap