October 2017
Intermediate to advanced
280 pages
6h 50m
English
Although the template syntax gives meaning of the code to the IDEs or text editors we use, it is quite verbose. Angular provides an alternative syntax, which will be desugared to the one shown in the preceding snippet.
There are a few Angular directives that require a ng-template element, for example, ngForOf, ngIf, and ngSwitch. Since such directives are used often, there's an alternative syntax for them. Instead of typing the entire ng-template element explicitly, we can simply prefix the directive with *. This will allow us to change our ngForOf directive syntax usage as follows:
<!-- ch5/ng-for/syntax-sugar/app.html -->
<ul>
<li *ngFor="let todo of todos">{{todo}}</li>
</ul>
Later, this template will be ...
Read now
Unlock full access