You can do the formatting directly in the view, without having to manipulate the value through a filter
or directive
customized. Example:
$scope.meuValor = 10.3
<p>Valor: {{meuValor | currency}}</p>
If the automatic conversion is not done (added the R$), you can still set the display options, according to the documentation here, as the currency and number of houses after the comma.
{{campo | currency:sigla:casas}}
{{campo | currency:'R$':2}}
Take an example: http://jsfiddle.net/gwxvu921/
Edited:
I had forgotten the .
separation of decimal place. This can be solved by using a file locale
, like this: https://github.com/renato/bower-angular-locale-pt-br/blob/master/angular-locale_pt-br.js
Just load this file at the index, or as you see fit. I, for example, concatenate it with other function files by mounting a module I load as a dependency of module
leading.
excellent, I didn’t even remember that question. a detail is that the question was about Angularjs not Angular 2 ( 4.0) but as I am already working on 4.0 ended up helping me without wanting rsrs
– LeandroLuk