Structural Directives

Last updated

What is Structural Directives?

Structural directives are directives applied to an <ng-template> element that conditionally or repeatedly renders the content of that <ng-template>. If you just wrap elements in an <ng-template> without applying a structural directive, those elements will not be rendered.

In Angular, there are three standard structural directives:

  • *ngIf – conditionally includes a template depending on the value of an expression returned by a Boolean.
  • *ngFor – makes it simple to iterate over an array.
  • *ngSwitch – renders each matching view.

Free resources to learn Structural Directives

More in stage 9: Directives

Structural Directives: common questions

Can I learn Structural Directives in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Structural Directives in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Structural Directives tutorial for beginners?

It is lesson 37 of 158 in the free Angular roadmap, in stage 9, Directives. If you are new to Angular, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me