Problem Statement
What are structural directives and how do *ngIf and *ngFor work?
Explanation
Structural directives change the layout by adding or removing elements. *ngIf inserts the host element only when the condition is truthy. *ngFor repeats the host element for each item in a list. Under the hood, the asterisk is shorthand for using <ng-template> with the directive’s microsyntax.
Code Solution
SolutionRead Only
<div *ngIf="loggedIn">Welcome!</div>
<li *ngFor="let user of users; index as i">{{ i }} — {{ user.name }}</li>