解决 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 须要的写上工夫格局