angular: Methods in templates don't understand Infinity value
I’m submitting a…
Bug report
<button (click)="setMax(Infinity)"></button>
Current behavior
setMax gets undefined
Expected behavior
setMax has to get Infinity
Minimal reproduction of the problem with instructions
http://plnkr.co/edit/GisrghRD3HQkn0wcRdR7?p=preview
Environment
Angular version: 4.4.4
Browser: any
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (12 by maintainers)
@Methods … you can’t use a global thing for a direct template binding, only through a class’s property.
Template "variable"s are properties of context object, it’s the nature of semantic for not having access to JavaScript
[[global]]properties. Instead, properties on__proto__are always accessible, so there’s a common case for usingconstructortemplate “variable” to access static properties like{{ constructor.name }}.I’m opposing to a semantic-level exception in the template language just because something is a bit more common. Adding support for
To observe the the existence ofundefinedcould just be a design mistake in the very first version. A significant evidence is that AngularJS does not supportundefinedin template.undefined, a string concatenation like{{ undefined + '' }}can be used.@tytskyi In Angular template
undefinedis treated specially like a keyword/literal (by lexer), changing the context value won’t affect it. Similar tocontext.true = falsewon’t change the meaning oftruein template.The problem is why
undefinedgot special treatment while other globals (Infinity,NaN) aren’t.