Hi Here I wrote a custom directive. That directive need to call for each time when value changed. Here is my directive. How can I call in ng-change.here is my directive.
app.directive('percentageFormatter', function() { return { require: 'ngModel', link: function(scope, element, attrs, ngModelController) { ngModelController.$parsers.push(function(data) { //convert data from view format to model format return data.replace('%',''); }); ngModelController.$formatters.push(function(data) { //convert data from model format to view format return data+'%'; }); } } }); JSP:-
<input type="text" percentage-formatter ng-model="tea"> Here How to call that directive in ng-change.