I saw that the variables end in $ when reading the hero's official textbook:
<div id="search-component"> <h4>Hero Search</h4> <input #searchBox id="search-box" (keyup)="search(searchBox.value)" /> <ul class="search-result"> <li *ngFor="let hero of heroes$ | async" > <a routerLink="/detail/{{hero.id}}"> {{hero.name}} </a> </li> </ul> </div>
Look carefully and you will see that * ngFor iterates over the list of heroes$ , not heroes .
<li *ngFor="let hero of heroes$ | async" >
$ is a convention that indicates that $ characters are observable, not an array.
In most cases, we do not subscribe to these observable variables in the component. We usually use AsyncPipe to automatically subscribe to Observable variables.
I did not find it in the Style Guide since Angular5.1 released yesterday (December 6, 2017).
haifzhan Dec 07 '17 at 22:51 on 2017-12-07 22:51
source share