我使用角度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;
};
});
答案 0 :(得分:1)
看起来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;
};