If you whant to map string value to <input type="time">
you will get Error: error:datefmt Model is not a date object
from angular 1.3 and upper.
Solution is to use string to date conversion directive. Like this one:
JsFiddle working example.directive("strToTime", function () {
return {
require: 'ngModel',
link: function (scope, element, attrs, ngModelController) {
ngModelController.$parsers.push(function (data) {
if (!data)
return "";
return ("0" + data.getHours().toString()).slice(-2) + ":" + ("0" + data.getMinutes().toString()).slice(-2);
});
ngModelController.$formatters.push(function (data) {
if (!data) {
return null;
}
var d = new Date(1970, 1, 1);
var splitted = data.split(":");
d.setHours(splitted[0]);
d.setMinutes(splitted[1]);
return d;
});
}
};
});