Display Currency with all decimals intact in AngularJS -
i need display currency format decimal places intact.
if value amount is: 123456.789
output should 1,23,456.789 $
if write
{{amount | currency:$}}
output is:1,23,456.78 $
[removes last digit]if write
{{amount | currency:$:3}}
, output is:1,23,456.78 $
[it displays expected]
but problem can not fix number of decimals keeps changing.
got resolution. implemented following custom filter(currency symbol not mandatory :) )
myapp.filter('customnumber', function($filter) { var standardnumfilterfn = $filter('number'); return function(num) { if(num){ var numsplit = (''+num).split('.'); if(numsplit && numsplit[1]){ return standardnumfilterfn(num, (''+numsplit[1]).length); } return standardnumfilterfn(num, 0); } }; });
and then:
{{amount | customnumber}}
Comments
Post a Comment