-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$filter number: Could we display an Infinity symbol in case of Infinity value? #10421
Comments
I wonder if CLDR includes localized "infinity symbols", hah. @petebacondarwin wdyt? Doesn't seem like a big deal to me (I would label this as "Good First Bug" if we had the label already) |
@QuentinFchx you can submit a PR, I'll be happy to review it, it doesn't seem unreasonable and it's pretty low impact so go for it. It should be pretty obvious what to do --- check if abs(number) is Infinity, and if it is, return a symbol (if CLDR does actually localize this, we should use a localized version if available, but I doubt it does). Then just add some tests demonstrating that it does work correctly. Should take all of 10 minutes to write up. |
Thanks for your quick answer ! I started to dive into the filter's code. Also, there is no Infinity symbol in the locales. Should we add it there aswell ? |
I'm half-joking about localizing the infinity symbol --- I expect there's no CLDR data for localized Infinity. If someone proves me wrong then sure, but that's a bigger project than this and it's not worth going for it just for this |
Might this line kill Buzz Lightyear dreams (and mines too ?) then ? |
well if they're getting that from CLDR then we probably do want to add that --- but for this patch I wouldn't worry about it. |
Fine ! |
I never agreed on that in the first place, but do it how you like |
It seems like the associated PR was moved to 1.4.x so moving the issue as well. |
landed as #10422 |
Infinity is a value and should not be treated as an empty string Closes #10421
I think this issue is not yet completely fixed. I explain myself with some bits of code: Infinity (1): <span>{{1/0 | number:4}}</span><br>
Infinity (2): <span>{{Infinity | number:4}}</span><br>
Infinity (3): <span>{{'Infinity' | number:4}}</span><br>
Please note infact that calling Therefore I believe that most likely the problem resides in the expression evaluation. |
I think it works as expected.
Keep in mind, that JS expressions in the controller are evaluated against the global object, whereas Angular expressions in the view are evaluated against the local |
Okay, I get it. Sorry and thanks. |
Could we display an Infinity symbol (∞) instead of an empty string through the "number" filter, when it's applied to
Infinity/-Infinity
?According to this thread, we could use
∞
or∞
(decimal) or∞
(hex)I can come with a PR if it's in the framework's scope. I guess we only have to add a case here.
The text was updated successfully, but these errors were encountered: