O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Update on templates

As the template is a real HTML tag for the web component, Angular introduced a new ng-template tag for templates. Angular enabled us to use else in ngIf in templates, as follows:

<div *ngIf="isOld; then   content else new_content">placeholder</div>   
<ng-template   #content><h2>old content body.</h2></ng-template>   
<ng-template   #new_content><h2>body of new content.</h2></ng-template>   

Here, if isOld is true, the content of the old template will be displayed. Otherwise, the content of the new template will be displayed.

Next, let's discuss the as keyword added to the template syntax. It is introduced to simplify the syntax of let. It enables us to store the results in a template variable:

 <ul> <li *ngFor="let book of books | ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required