【发布时间】:2015-09-15 05:55:01
【问题描述】:
我正在学习 angularjs 并使用 angularjs 材质 datepicker 组件进行日期控制,但它不起作用,我使用的代码与 material.angularjs.org 中的代码相同,但我的控件没有显示请帮忙。 我的 html 页面是 DatePicker.html:
<!DOCTYPE html>
<html ng-app="datepickerBasicUsage">
<head>
<title></title>
<link href="angular-material.min.css" rel="stylesheet" />
<script src="angular.min.js"></script>
<script src="angular-animate.min.js"></script>
<script src="angular-aria.min.js"></script>
<script src="angular-material.min.js"></script>
<script src="myapp.js"></script>
</head>
<body>
<div ng-controller="AppCtrl" style='padding: 40px;'>
<md-content>
<h4>Standard date-picker</h4>
<md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>
<h4>Disabled date-picker</h4>
<md-datepicker ng-model="myDate" placeholder="Enter date" disabled></md-datepicker>
<h4>Date-picker with min date and max date</h4>
<md-datepicker ng-model="myDate" placeholder="Enter date" md-min-date="minDate" md-max-date="maxDate"></md-datepicker>
</md-content>
</div>
</body>
</html>
myapp.js
angular.module('datepickerBasicUsage', ['ngMaterial'])
.controller('AppCtrl', function($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());
});
以上是我从网站文档中获得的代码。 但它不起作用,我做错了什么。请帮忙。
【问题讨论】:
-
您检查调试控制台是否有错误?
-
@Michelem - 没有错误,我的页面正在打开,但它只显示标签而不是控件
-
我遇到了类似的问题,但很有趣的是,我意识到我使用的是 0.10.1 版本,并且最近在 0.11.0 版本中引入了 datepicker
-
在这种类型的日期选择器中有月份年份选择器吗?
标签: angularjs datepicker