-
Notifications
You must be signed in to change notification settings - Fork 27k
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 interpolationfeatureIssue that requests a new featureIssue that requests a new feature
Milestone
Description
🚀 feature request
Description
I'd like to have your opinions about supporting "in" operator in html templates. Let's say I have an object of a union type A | B. I'd like to use the 'in' operator to differentiate type.
Something like:
export interface A {
a: number
}
export interface B {
b: string
}
export type MyUnionType = A | B;
item: MyUnionType = {
a: 1
}
<div *ngIf="'a' in item">
I'm expecting item is no longer of type A | B, but only A
{{item.a}}
</div>
Here is a stackblitz
LastDragon-ru, dexterbt1, samuelfernandez, rlmestre, ertunga and 9 more
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 interpolationfeatureIssue that requests a new featureIssue that requests a new feature