Enable Nullish Coalescing operator in angular template
See original GitHub issueπ feature request
Relevant Package
This feature request is for @angular/coreDescription
What do you think about enabling Nullish Coalescing also in angular template?
I often write for example something like this:
<span [title]="variable != null ? variable : ''">
s.t if variable = 3, title = β3β if variable = 0, title = β0β if variable = null, title = ββ, meaning the html tooltip title is hidden
Describe the solution youβd like
It would be nice in my opinion to write something like:
<span [title]="variable ?? ''">
to obtain the same results with a less verbose syntax.
It may be also helpful in other situations, in template interpolation {{ β¦ }}, etc
What do you think? Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:169
- Comments:15
Top Results From Across the Web
Nullish Coalescing support in Angular template
The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null orΒ ......
Read more >Angular Nullish Coalescing Operator (??) - ConcretePage.com
The nullish coalescing operator (??) is a logical operator that has following syntax. ... If left-hand side operand is null or undefined ,...
Read more >Nullish Coalescing support in Angular template - Avinash Dalvi
The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null or...
Read more >NG8102: Nullish coalescing not nullable - Angular
This diagnostic detects a useless nullish coalescing operator ( ?? ) characters in Angular templates. Specifically, it looks for operations where the inputΒ ......
Read more >Angular Equivalent of Null Coalescing Operator in HTML ...
Note: If you enable this.item.ProductName="P-Name"; this line it will show "P-Name" otherwise it will show "P-Type"Β ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
bump*
The nullish coalescing operator would be a much preferred way to handle the current
AsyncPipe
workaround fornull | undefined