繁体   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