AngularJS - Formatowanie modelu ng przed renderowaniem szablonu w dyrektywie niestandardowej
Tworzę niestandardową dyrektywę w Angular JS. I chcę sformatować model ng przed renderowaniem szablonu.
Oto, co mam do tej pory:
app.js
app.directive('editInPlace', function() {
return {
require: 'ngModel',
restrict: 'E',
scope: { ngModel: '=' },
template: '<input type="text" ng-model="ngModel" my-date-picker disabled>'
};
});
html
<edit-in-place ng-model="unformattedDate"></edit-in-place>
Chcę sformatować wartość unformattedDate, zanim zostanie wprowadzona w ngModel szablonu. Coś takiego:
template: '<input type="text" ng-model="formatDate(ngModel)" my-date-picker disabled>'
ale to daje mi błąd. Jak to zrobić?