Reputation: 1522
I am new to angular. The requirement is-
I have an input field for amount in different currency.My requirement is that ,Once user tabs out,I want the comma to get added automatically, based on number of digits in the amount.Also,if amount entered does not include a decimal value,then .00 should get auto added to the amount.
Upvotes: 1
Views: 1239
Reputation: 173
first create an input with a directive (add-commas
in this case)
<input type="text" add-commas />
Create a directive that registers an event handler for the inputs blur
event like so
angular.module('app', [])
.directive('addCommas', function(){
return {
link: function(scope, el, attrs){
el.bind('blur', function(){
// Add the commas and stuff
});
}
}
});
I created a plunker that should meet your requirements.
Hope this helps
Upvotes: 1