我使用角度材质,我想实现md-datepicker。我做了类似的事情:
<md-input-container flex="100" layout="row">
<div flex="45">
<md-datepicker ng-model="$ctrl.myDate" placeholder="Enter date"></md-datepicker>
</div>
</md-input-container>
Js看起来像这样:
var ctrl = this;
ctrl.myDate = new Date();
我有enter image description here 我错在哪里?
答案 0 :(得分:0)
确保已加载正确的库和版本。
<强>样本强>
angular.module('datepickerBasicUsage', ['ngMaterial'])
.controller('AppCtrl', function ($scope) {
});
&#13;
<!doctype html>
<html ng-app="datepickerBasicUsage">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.css">
<script src="app.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>
</md-content>
</div>
</body>
</html>
&#13;
答案 1 :(得分:0)
找到问题,但不知道为什么会发生。当我更换
<script type="text/javascript" src="../node_modules/angular-material/angular-material.js"></script>
到:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.js"></script>
问题已经消失,但是我想要本地src所以尝试npm install,在删除带有角度材质的文件夹之后,但它没有帮助