Help with Mask Directive for 4 decimal digits in Angularjs

Asked

Viewed 1,338 times

2

I want to make a number directive in Angularjs with two features, one to format when typing a number in an html input.

Example of how you would like :
1,200,0000
12.000,0000
120,000,0000

and the other to limit the decimal places to 4 boxes after the comma.

Someone has an idea?

  • Have you tried using the ng-currency? Ex: http://plnkr.co/edit/u9mJqDH8UpwxDnOv8gZL?p=preview

  • That’s just what I needed, but I tried it here and it didn’t work the example, I added the ng-currency script, and I have the en locale, the console does not accuse any errors, have some extra config to add?

  • Did you put the directive in your html? You stated it in the app?

  • angular.module('myApp', ['ng-currency']);

  • Perfect, I had forgotten this detail, it worked right, thank you very much.

  • Nothing, since it worked I’ll answer the question.

Show 1 more comment

1 answer

0


You can use the library ng-currency, with this library you can format your decimal places. Here is a simple example of how to use the library.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.