July 2017
Intermediate to advanced
384 pages
8h 23m
English
Angular has a lot of built-in directives: ngIf, ngFor, ngSwitch, ngClass, and ngStyle. The first three directives are so called structural directives, which are used to transform the DOM's structure. Structural directives start with an asterisk (*). The last two directives manipulate the CSS classes and styles dynamically. Let's explain the directives in the examples.
The ngIf directive adds and removes elements in the DOM, based on the Boolean result of an expression. In the next code snippet, <h2>ngIf</h2> is removed when the show property evaluates to false and gets recreated otherwise:
<div *ngIf="show"> <h2>ngIf</h2></div>
Angular 4 has introduced a new else clause with the reference name for a template defined ...
Read now
Unlock full access