Angular structural directives — implement your own *ngIf

Explore the magic behind the asterisk

Kevin Kreuzer
Jun 2 · 4 min read

Angular provides a couple of built-in directives. But not all of them are applied in the same way. ngClass for example, is applied like a normal HTML attribute. Structural directives like *ngIf or *ngFor on the other hand, are used with a leading asterisk (*).

It’s this asterisk we want to talk about in this blog post. What is it doing under the hood?