Structural directives

Change the strucutre of the DOM around the element. If You have ngIf on a paragraph, and if that condition is false, this paragraph is removed from the DOM.

  • Look like a normal HTML element, but have a leading *
  • Affect a whole area in the DOM (elements get added / removed)
[ngClass]="{ odd: odd % 2 !== 0 }"
[ngStyle]="{ backgroundColor: odd % 2 !== 0 ? 'yellow' : 'transparent' }"

Even / Odd numbers toggle

Was this page helpful?