A more efficient way than defining a template variable in @if
/ ngIf
is to use the new @let
syntax introduced in Angular 18:
@let variable = signal().object?.nestedObject;
@if (isTypeA(variable)) {
{{ variable.TypeAUniqueProperty }}
} @else if (isTypeB(variable)) {
{{ variable.TypeBUniqueProperty }}
}