我想在输入类型中输入一个字符串" time"在我的代码html
<label class="item item-input">
<span class="input-label">Heure de départ </span>
<input type="time" ng-model="heureDepart" id="time" >
</label>
当我直接说出来时,它显示了我的错误:
Error: [ngModel:datefmt] Expected `05:01:01` to be a date
http://errors.angularjs.org/1.3.13/ngModel/datefmt?p0=05%3A01%3A01
at REGEX_STRING_REGEXP (ionic.bundle.js:8890)
at Array.<anonymous> (ionic.bundle.js:28634)
at Object.ngModelWatch (ionic.bundle.js:32116)
at Scope.$get.Scope.$digest (ionic.bundle.js:23062)
at Scope.$get.Scope.$apply (ionic.bundle.js:23333)
at HTMLBodyElement.<anonymous> (ionic.bundle.js:20191)
at HTMLBodyElement.eventHandler (ionic.bundle.js:11841)
at triggerMouseEvent (ionic.bundle.js:2865)
at tapClick (ionic.bundle.js:2854)
at HTMLDocument.tapMouseUp (ionic.bundle.js:2927)(anonymous function) @ ionic.bundle.js:20434$get @ ionic.bundle.js:17384$get.Scope.$digest @ ionic.bundle.js:23088$get.Scope.$apply @ ionic.bundle.js:23333(anonymous function) @ ionic.bundle.js:20191eventHandler @ ionic.bundle.js:11841triggerMouseEvent @ ionic.bundle.js:2865tapClick @ ionic.bundle.js:2854tapMouseUp @ ionic.bundle.js:2927
livereload.js?snipver=1:191 WebSocket connection to 'ws://localhost:35729/livereload' failed: WebSocket opening handshake timed out
我该怎么办?
答案 0 :(得分:0)
问题解决了
我在控制器中添加了这个:
var heure=$state.params.heure+"";
var h=heure.substring(0, 2);
var m=heure.substring(3, 5);
var s=heure.substring(6, 9);
$scope.heureDepart = { value: new Date(1970, 0, 1, h, m, s ) };
和ng-model="heureDepart.value"
到我的ng-model
答案 1 :(得分:-1)
您需要遵循时间格式。格式为'HH:mm','HH:mm:ss'或'HH:mm:ss.SSS',其中HH为00-23,mm为00-59,ss为00-59,SSS为000- 999。
所以,如果我想将它设置为10:23:24 PM,我会使用jQuery:
$('#time').val('22:23:24');
这是codepen