September 2017
Intermediate to advanced
450 pages
11h 24m
English
Sometimes in a template, it can be useful to assign the value from a particular piece of logic to a local variable to use in the template itself. This is especially useful when the value of the logic is looking at, is an observable which has to resolve asynchronously before data is made available to the template. For example, consider the case of loading the details for a movie in Angular. The user selects a movie title and the app will fetch additional details via an API request:
<div *ngIf="movieDetailsObservable | async; else loading; let movie"> <h1>{{movie.releaseDate}} - {{movie.director}}</h1> <p>{{movie.description}}</p></div><ng-template #loading>Loading...</ng-template>
The template has a conditional ...
Read now
Unlock full access