我正在尝试将angular js datepicker注入我的项目中。我完成了根据文件。但似乎没有任何可见的日期选择器。 我创建了一个plnkr plnkr
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://rawgit.com/g00fy-/angular-datepicker/master/app/styles/bootstrap.css">
<link rel="stylesheet" href="https://rawgit.com/g00fy-/angular-datepicker/master/dist/angular-datepicker.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.4.1/moment-timezone-with-data.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap-tpls.min.js"></script>
<script src="https://rawgit.com/g00fy-/angular-datepicker/master/app/scripts/datePicker.js"></script>
<script src="https://rawgit.com/g00fy-/angular-datepicker/master/app/scripts/datePickerUtils.js"></script>
<script src="https://rawgit.com/g00fy-/angular-datepicker/master/app/scripts/dateRange.js"></script>
<script src="https://rawgit.com/g00fy-/angular-datepicker/master/app/scripts/input.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<input class="form-control" date-time ng-model="DateOfbirth" max-date="today" view="date" timezone="UTC" format="yyyy-MM-dd HH:mm">
</body>
</html>
doc ref。 here
答案 0 :(得分:0)
我遇到了同样的问题。
尝试将角度版本升级到1.5.X
最低/最低日期所需的一些功能不包括在最低
中角度版本。
答案 1 :(得分:0)
我通过添加自定义$watch
修复了我的问题。
$scope.$watch('addUserProfileData.DateOfbirth', validate_dateOfbirth);
function validate_dateOfbirth () {
if ( $scope.addUserProfileData.DateOfbirth != "" ) {
var selectedDate = moment($scope.addUserProfileData.DateOfbirth.toISOString()).format('DD/MM/YYYY');
var current_date = moment(moment().toISOString()).format('DD/MM/YYYY');
var momentA = moment(selectedDate,"DD/MM/YYYY");
var momentB = moment(current_date,"DD/MM/YYYY");
if (momentA >= momentB) {
$scope.addUserProfileForm.DateOfbirth.$setValidity("endBeforeStart", false);
} else {
$scope.addUserProfileForm.DateOfbirth.$setValidity("endBeforeStart", true);
}
}
}