Datepicker获取日期并将其放入input
字段。输入标记为required
,但AngularJS无法查看更改并将其标记为有效。为什么呢?
HTML
<div class="form-group" ng-class="{ 'has-error': myForm.inputDatetimeStart.$invalid }">
<label for="datetimepicker_start" class="col-sm-3 control-label">Start date and time: </label>
<div class="col-sm-8">
<input class="form-control" name="inputDatetimeStart" ng-model="datetime_start" id="datetimepicker_start" type="text" required>
</div>
</div>
JS
angular.module('myApp', ['ajoslin.promise-tracker', 'ngRoute'])
.controller('myCtrl', function ($scope, $http, $log, promiseTracker, $timeout){
jQuery('#datetimepicker_start').datetimepicker({ });
...
}
答案 0 :(得分:1)
尝试使用
$scope.$watch('datetime_start', function () {
$scope.$apply();
})
它会使消化周期发生。