You can chain two number filters like this:
{{ myNumber | number:2 | number }}
On Sunday, 23 June 2013 01:34:42 UTC+3, Christophe Levesque wrote:
>
> Reviving and old thread but the number filter has an odd behavior. When
> not specifying the number of decimals {{myNumber | number}}, angular format
> with up to 3 decimals:
>
> - 123.4567 gets formatted as 123.457
> - 123 gets formatted as 123 (no decimals shown)
>
> However, when specifying the number of decimals {{myNumber | number:2}},
> angular forces them to appear even for integers:
>
> - 123.4567 gets formatted as 123.46
> - 123 gets formatted as 123.*00*
>
> Is there a way to set the *maximum* number of decimals so that 123 would
> still appear as 123 without writing a custom filter?
>
> Thanks,
>
> Christophe
>
>
> On Thursday, August 30, 2012 11:20:06 AM UTC-7, Andy Joslin wrote:
>>
>> Unfortunately, docs.angularjs.org is down.. but this works:
>> https://github.com/angular/angular.js/blob/master/src/ng/filter/filters.js#L54
>>
>> {{myNumber | number:2}} takes it to two decimals
>>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.