我已经使用$filter('date')($scope。booktime, 'mediumTime'),同时预订。预订后,我有编辑预订功能,当我通过时间,我在控制台得到错误错误:[ngModel:datefmt]预期11:59:00 AM
是一个日期,我怎么能解决这个问题,因为3天我无法解决这个错误。我想通过11:59:00 AM时间输入字段
function HistoryCtrl($scope, $filter) {
$scope.booktime = "11:59:00 AM";
}
<div ng-app ng-controller="HistoryCtrl">
<div class="col">
<label class="item item-input item-stacked-label">
<span class="input-label" >Time</span>
<input type="time" ng-model="booktime" name="booktime" min="09:00:00" max="21:00:00" required="">
</label>
<div class="form-error" ng-messages="projectForm.booktime.$error">
<div class="form-error" ng-message="required">* Mandatory</div>
<div class="form-error" ng-message="min">Booking times: 9am - 9 pm</div>
<div class="form-error" ng-message="max">Booking times: 9am - 9 pm</div>
</div>
</div>
</div>
您需要正确格式化它,使用日期过滤器(或从您的字符串中删除"AM"):
JSFiddle
app.controller('controller', ['$scope', '$filter', function ($scope, $filter) {
$scope.booktime = $filter('date')(new Date(), 'HH:mm')
}]);