ngIf
The ngIf
directive is used to include an element and its content in the HTML document if the expression evaluates as true.
Example
<div *ngIf="getCartSize() = 0">
Your shopping cart is empty
</div>
ngFor
The ngFor
directive is used to generate the same set of elements for each object in an array.
Example
<table>
<tr><th>Name</th><th>Category</th><th>Price</th></tr>
<tr *ngFor="let item of productList">
<td>{{item.name}}</td>
<td>{{item.category}}</td>
<td>{{item.price}}</td>
</tr>
</table>