Skip to content

Enable Nullish Coalescing operator in angular template #36528

@manueledones

Description

@manueledones

🚀 feature request

Relevant Package

This feature request is for @angular/core

Description

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!

Metadata

Metadata

Assignees

Labels

area: compilerIssues related to `ngc`, Angular's template compilerarea: coreIssues related to the framework runtimecore: binding & interpolationIssue related to property/attribute binding or text interpolationfeatureLabel used to distinguish feature request from other issuesstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions