您好我使用角料日期选择器。 小问题是,当我点击日期并打开日历时 - 它会打开并显示今天不是日期。但是有些遥远的日期。 如何在今天或至少在ng-model日期打开日历?
显示日期:
单击时打开日历:
这里是html:
<md-datepicker class="font" ng-model="vm.startDate"></md-datepicker>
获取模型:
vm.startDate = new Date();
提前感谢您的帮助。
更新: 注意到了奇怪的行为:
CASE1: 当我滚动页面和日历几乎在页面顶部时:
当我打开日历时,它会显示当前日期:
CASE2: 同样但当datepicker在底部页面滚动时: 目前的日期,如果远远落后......
答案 0 :(得分:3)
<强>样本强>
angular.module('datepickerBasicUsage', ['ngMaterial'])
.controller('AppCtrl', function ($scope) {
var vm = this;
vm.startDate = new Date();
});
&#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 as vm" style='padding: 40px;'>
<md-content>
<h4>Standard date-picker</h4>
<md-datepicker ng-model="vm.startDate" md-placeholder="Enter date"></md-datepicker>
</md-content>
</div>
</body>
</html>
&#13;