
上QQ阅读APP看书,第一时间看更新
Local variables in templates
Let us see the example of using local variables in ng-repeat and ngFor in AngularJS and Angular, respectively.
AngularJS:
<tr ng-repeat="book in vm.books"> <td>{{book.name}}</td> </tr>
Angular:
<tr *ngFor="let book of books"> <td>{{book.name}}</td> </tr>
Notice that the local variable book is implicitly declared in AngularJS and in Angular the let keyword is used to define the local variable book.