簡體   English   中英

在角度模態中設置默認時間

[英]Set default time in angular modal

如何在角度模型中設置默認時間值?

的HTML

<input id="starttime_mon" name="starttime_mon" ng-model="starttime[1]" ng-disabled="!search_dow_number[1]" type="time" class="form-control" />
<input id="endtime_mon" name="endtime_mon" ng-model="endtime[1]" ng-disabled="!search_dow_number[1]" type="time" class="form-control"  />

JS

$scope.starttime = new Date(1970, 0, 1, 0, 0, 0);
$scope.starttime = '00:00;
$scope.starttime[1] = new Date(1970, 0, 1, 0, 0, 0);

在上一次嘗試時,我得到錯誤:無法設置未定義的屬性“ 1”。我嘗試過的其他操作未得到任何結果。

因此, new Date意味着$scope.starttime不是對象,因此它不具有您嘗試使用$scope.starttime[1]從中獲取的1屬性。

很難理解您的意思,但我認為您不需要[1]:

JS

$scope.starttime = new Date(1970, 0, 1, 0, 0, 0);

的HTML

<input id="starttime_mon" name="starttime_mon" ng-model="starttime" ...

檢查一下:

  <input type="time" ng-model="timeModel"/> 
  $scope.timeModel = new Date(2010, 11, 28, 14, 57);

https://plnkr.co/edit/DIvGpXrPkmqRMnNpDWlH?p=preview 希望能幫助到你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM