Structural directives

Structural directives have a lot in common with attribute directives, in terms of how they are created, but they are very different in how they are expected to behave. A structural directive, unlike an attribute directive, is expected to create or remove a DOM element. This is different from using a CSS display property to show or hide an element. In this case, the element is still in the DOM tree but is not visible to the end user when hidden.

A good example is *ngIf. When an element is removed from the DOM using an *ngIf structural directive, the directive both disappears from the screen and gets deleted from the DOM tree.

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.