![](/img/trans.png)
[英]angular material (md-datepicker) - how to set different date format to different datepicker in one page
[英]How to initialize the date value of Angular Material md-datepicker to any specified date
在Angular Material md-datepicker中,當我單擊日期選擇器時,它將系統的當前日期設置為今天的日期。 我們注意到今天的日期在日期選擇器的日歷中圈出。 我想知道是否有辦法將任何給定日期設置為今天的日期。 請參考此圖片。 md-datepicker的日歷(今天的日期以黃色突出顯示)
因此,在我的情況下,如果我將今天的日期設置為2017年4月2日,則datepicker應將此設置為今天的日期,並在日歷上圈出此日期
HTML
<md-content ng-controller="AppCtrl as ctrl" layout-padding="" ng-cloak="" class="datepickerdemoBasicUsage" ng-app="MyApp">
<div layout-gt-xs="row">
<div flex-gt-xs="">
<h4>Standard date-picker</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date"></md-datepicker>
</div>
</md-content>
JS
angular.module('MyApp',['ngMaterial', 'ngMessages', 'material.svgAssetsCache']).controller('AppCtrl', function() {
this.myDate = new Date('2017-04-17T03:24:00');
this.isOpen = false;
});
this.myDate =新日期('2017-04-17T03:24:00');
您可以在此處設置自己的日期。 在您的情況下,您希望2017年4月2日作為日期時間選擇器中的默認日期,那么您應該寫
this.myDate =新日期('2017-04-01T03:24:00');
我為此提到了Angular Material網站
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.