79267603

Date: 2024-12-10 09:10:50
Score: 1.5
Natty:
Report link

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 }}
}

See the official documentation.

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: fservantdev