-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Enable Nullish Coalescing operator in angular template #36528
Copy link
Copy link
Closed
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerarea: coreIssues related to the framework runtimeIssues related to the framework runtimecore: binding & interpolationIssue related to property/attribute binding or text interpolationIssue related to property/attribute binding or text interpolationfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesstate: has PR
Milestone
Description
🚀 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!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerarea: coreIssues related to the framework runtimeIssues related to the framework runtimecore: binding & interpolationIssue related to property/attribute binding or text interpolationIssue related to property/attribute binding or text interpolationfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesstate: has PR