2015-09-15 26 views
0

我預訂時使用$ filter('date')($ scope.booktime,'mediumTime')存儲了時間。預訂後,我有編輯功能,當我通過時間,我得到控制檯錯誤錯誤:[ngModel: datefmt]預期11:59:00 AM是如何解決這個我嘗試SICE3天我不能夠解決這個error.i要上午11時59分00秒通過時間輸入欄的日期爲什麼時間輸入提交期望在angularjs中的日期?

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>

回答

0

您需要正確格式化它,使用日期過濾器(或從您的字符串中刪除「AM」):

JSFiddle

app.controller('controller', ['$scope', '$filter', function ($scope, $filter) { 
    $scope.booktime = $filter('date')(new Date(), 'HH:mm') 
}]); 
+0

如何傳遞這個上午11時59分00秒 –

+0

同時預訂我已經通過了一次這樣的檢查http://jsfiddle.net/nbqo17xm/ –

+0

如果你不使用type =時間想添加上午/下午或使用此指令https://github.com/phng/angular-input-time –

相關問題