当我单击CheckTime按钮时,时间值不会传递给控制器
<div class='input-group date datetimepicker-2'>
<input type='text' class="form-control" name="FromTime" ng-init="FromTime = (date: 'hh:mm:ss')" ng-model="FromTime" placeholder="From Time" />
<span class="input-group-addon">
<i class="font-icon font-icon-clock"></i>
</span>
</div>
AngularJS:
$scope.CheckTime = function () {
alert("Time, " + $scope.FromTime);
};
答案 0 :(得分:1)
ng-init =“ FromTime =(date:'hh:mm:ss')”
这不是将值分配给FromTime的正确方法。
如果您要使用特定日期初始化FromTime,请使用一个变量并为其分配一个日期,然后在 ng-init 中使用它。
<div class='input-group date datetimepicker-2'>
<input type='text' class="form-control" name="FromTime" ng-init="FromTime = myDate" ng-model="FromTime" placeholder="From Time" />
<span class="input-group-addon">
<i class="font-icon font-icon-clock"></i>
</span>
</div>
在控制器中,
$scope.myDate = new Date();
$scope.FromTime =null;