Reputation: 2749
I just upgraded to angular version 1.2.1 from version 1.0.8 and my custom directive has stopped working. This directive is supposed to format a date that's bound to a text input via ng-model. Here's the directive and the HTML and here's a plunker example that works in 1.0.8 but not 1.2.1:
app.directive('uiDate', function ($filter, $parse) {
return {
require: 'ngModel',
restrict: 'A',
link: function (scope, element, attrs, ngModel) {
// THIS FUNCTION ISN'T FIRING IN 1.2.1
ngModel.$render = function () {
element.val('formatted date goes here');
//element.val(formatDate(ngModel.$modelValue));
};
}
};
});
<input type="text" ng-model="crazyDate" ui-date />
If there is a better way to format a Microsoft-serialized date that looks like '/Date(1380600000000)/' into a text input bound with ng-model, I welcome your thoughts on better solutions, but using a custom directive is the only way I could figure it out as a new angular user. Thanks for your help!
Andy
Upvotes: 0
Views: 113
Reputation: 10246
I updated your plunkr to a working one:
http://plnkr.co/edit/ZTWvnQkXOdVEM6j2ZKvT
Also, take a look at:
https://groups.google.com/forum/#!topic/angular/ZJi_t9aYC-o
Upvotes: 1