我正在尝试实现一个向<input type="date">
字段添加格式化程序的简单指令。该指令如下所示:
myApp.directive("date-format", function (dateFilter) {
return {
restrict: "A",
require: "ngModel",
link: function (scope, element, attributes, ngModelController) {
ngModelController.$formatters.push(function (modelValue) {
return modelValue && new Date(modelValue);
});
}
};
});
在我将其名称更改为mb-date-format
. 我创建了一个 JS 小提琴:http: //jsfiddle.net/HB7LU/4458/。它似乎可以与 , 等名称一起正常工作aaa
,bbb
但是当您将名称更改为, , ...ccc
时它会停止工作。jjj
zzz