+-

解决 angularJS ng-modal 和 input type datetime 的问题(输入日期和时间)
JS
.directive('formatDate', function ($filter) {
return {
require: 'ngModel',
link: function (scope, elem, attr, ngModelCtrl) {
ngModelCtrl.$formatters.push(function (modelValue) {
if (modelValue) {
return new Date(modelValue);
}
});
ngModelCtrl.$parsers.push(function (value) {
if (value) {
return $filter('date')(new Date(value), attr.timetype);
}
});
}
};
});
HTML
<input type="datetime-local" ng-model="PM.stareTime" format-date timetype="yyyy-MM-dd hh:mm">
timetype 需要的写上时间格式