Enter time type with angular.js

According to the input of Docs [time]: https://docs.angularjs.org/api/ng/input/input%5Btime%5D

this should be enough to use the input time type and bind it to a date object, however this will not work as I expected.

<input ng-model="time" type="time" placeholder="HH:mm" min="08:00" max="17:00" required >

and

$scope.time = new Date();

As a result, I would like to see only HH: mm in the input field.

Here is the jsfiddle to play with:

http://jsfiddle.net/U3pVM/7314/

+5
source share
4 answers

It seems to me that you need at least Angular 1.3.0 beta strong> for this to work, since it looks like it was introduced then.

Changelog :

...

Functions

: : , , -, , (46bd6dc8, # 5864)
....

+3

, , http://plnkr.co/edit/60aiH0eJ8ee0FlEsQE2m?p=info

momentjs , .

moment().second(0).milliseconds(0).toDate();
+2

input = "time" angularJS ng-model

HTML: <input type="time" ng-model="myTime"/>

, ,

$scope.myTime = new Date(response.data.start_time);

HH: MM: SS

0

$scope.time = new Date(); :

var d = new Date();
$scope.time = d.getHours() + ':' + d.getMinutes();

: http://jsfiddle.net/bitsmith/asjv8ycq/1/

0

All Articles