角度材料设计日期选择器
问题描述:
我使用角度1.6,材质设计1.1.1,而使用datepicker,就像他们在他们的文档中所说,我点击日期选择器时得到一个空窗口,它只显示天信(SSMTWTF),并且只有在该窗口内滚动时才会开始显示日期。 有什么建议吗?感谢角度材料设计日期选择器
<md-input-container flex>
<label>Pick a date</label>
<md-datepicker ng-model="myDate" name="dateField" md-min-date="minDate"
md-max-date="maxDate"></md-datepicker>
<div ng-messages="myOtherForm.dateField.$error">
<div ng-message="valid">The entered value is not a date!</div>
<div ng-message="required">This date is required!</div>
<div ng-message="mindate">Date is too early!</div>
<div ng-message="maxdate">Date is too late!</div>
</div>
</md-input-container>
的JS:
var app = angular.module('StarterApp', ['ngMaterial', 'ngMdIcons', 'ngMessages']);
app.controller('AppCtrl', function($timeout , $scope){
$scope.myDate = new Date();
$scope.minDate = new Date(
$scope.myDate.getFullYear(),
$scope.myDate.getMonth() - 2,
$scope.myDate.getDate());
$scope.maxDate = new Date(
$scope.myDate.getFullYear(),
$scope.myDate.getMonth() + 2,
$scope.myDate.getDate());
$scope.onlyWeekendsPredicate = function(date) {
var day = date.getDay();
return day === 0 || day === 6;
};
});
答
看起来有在1.6.x版的RC版本中的错误。只需使用Angular 1.5.9,这里是一个工作示例。
var myDate = new Date(2016, 11, 3);
$scope.minDate = new Date(
myDate.getFullYear(),
myDate.getMonth() - 2,
myDate.getDate());
$scope.maxDate = new Date(
myDate.getFullYear(),
myDate.getMonth() + 2,
myDate.getDate());
$scope.onlyWeekendsPredicate = function(date) {
var day = date.getDay();
return day === 0 || day === 6;
};
+0
Github问题在这里:https://github.com/angular/material/issues/10070 – domenu
请添加一段代码或JS小提琴链接 –
嘿Nobal,谢谢,片段加入到这个问题 –
感谢。请加JS部分 –