简体   繁体   English

在角度模态中设置默认时间

[英]Set default time in angular modal

How can i set a default time value in a angular model? 如何在角度模型中设置默认时间值?

HTML 的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 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);

on the last attempt i get:Error: Cannot set property '1' of undefined The other things i tried didn't give any result. 在上一次尝试时,我得到错误:无法设置未定义的属性“ 1”。我尝试过的其他操作未得到任何结果。

So new Date , means that $scope.starttime is not an object, so it does not have the 1 property you're trying to get from it using $scope.starttime[1] 因此, new Date意味着$scope.starttime不是对象,因此它不具有您尝试使用$scope.starttime[1]从中获取的1属性。

Having a bit of a hard time understanding what you mean, but I don't think you need the [1]: 很难理解您的意思,但我认为您不需要[1]:

JS JS

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

HTML 的HTML

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

Check this one: 检查一下:

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

https://plnkr.co/edit/DIvGpXrPkmqRMnNpDWlH?p=preview . https://plnkr.co/edit/DIvGpXrPkmqRMnNpDWlH?p=preview Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM