Saturday, 15 February 2014

angularjs - Angular directive with ngModelController formatter -



angularjs - Angular directive with ngModelController formatter -

i'm trying implement simple directive adds formatter <input type="date"> field. directive looks like:

myapp.directive("date-format", function (datefilter) { homecoming { restrict: "a", require: "ngmodel", link: function (scope, element, attributes, ngmodelcontroller) { ngmodelcontroller.$formatters.push(function (modelvalue) { homecoming modelvalue && new date(modelvalue); }); } }; });

it worked pretty until changed name mb-date-format. created js fiddle: http://jsfiddle.net/hb7lu/4458/. seems work names aaa, bbb, ccc , on, stops working when alter name jjj, zzz, ….

try camel casing directive name "dateformat" eg :

myapp.directive("dateformat", function (datefilter)

, in utilize in html

<input type="date" ng-model="date" date-format>

angularjs angularjs-directive angular-ngmodel

No comments:

Post a Comment