[英]How to set today date and time as default in angular-moment-picker
我正在為datetimepicker使用angular-moment-picker輸入,我想在輸入上設置今天的日期和當前時間。 這是我的源代碼。 你能幫我么。 謝謝
<input class="form-control"
format="DD/MM/YYYY HH:mm"
ng-model-options="{ updateOn: 'blur' }"
moment-picker="startDate"
id="startDate"
ng-model="startDate">
控制器初始化時設置默認值startDate
angular
.module('Demo', ['moment-picker'])
.controller('DemoController', ['$scope', function ($scope) {
$scope.startDate = moment();
}]);
在腳本文件中使用moment()方法。
您可以通過使用輸入控件中的start-date屬性來設置開始日期。 該值應該是一個矩對象。
<input class="form-control"
format="DD/MM/YYYY HH:mm"
ng-model-options="{ updateOn: 'blur' }"
moment-picker="startDate"
id="startDate"
ng-model="startDate"
start-date="startDate">
這是工作中的小提琴 。 在這里,我分別使用了矩矩和角矩庫以及模塊
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.