You could extend the pipe and make you're own. This is probably the best
way to get the exact format you want.

On Mon, Aug 8, 2016 at 9:30 AM, Ciprian Serbu <[email protected]>
wrote:

> actually chaining won't work if the number is greater or equal to 1000 as
> the first filter will add one or more commas and the number filter does not
> know how to parse numbers with commas, e.g. $filter('number')('1,000')
> returns an empty string
>
> you could try calculating the number of digits yourself and passing it to
> the filter: $filter('number')(x, Math.min(String(x).split('.')[1] || 0,
> 2))
>
> miercuri, 8 aprilie 2015, 10:03:55 UTC+3, Justinas Saldukas a scris:
>>
>> 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 https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Lucas Lacroix
Computer Scientist
System Technology Division, MEDITECH <http://ehr.meditech.com>
781-774-2293

-- 
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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to