Explain structural directives in angular.

963    Asked by RogerLum in Python , Asked on Nov 5, 2019
Answered by Arun Singh

Directives allow us to attach behavior to elements in the DOM, for example, doing something on mouse over or click. Structural directives change the DOM layout by adding and removing DOM elements. For example, *ngIf and *ngFor. Structural directives are responsible for HTML layout. They shape or reshape the DOM’s structure, typically by adding, removing, or manipulating elements. Structural directives are easy to recognize. An asterisk (*) precedes the directive attribute name as in this example.


  • {{name}}


The ngFor directive iterates over the component's names array and renders an instance of this template for each name in that array.

Some of the other structural directives in Angular are ngIf and ngSwitch.



Your Answer

Interviews

Parent Categories