- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 51字
- 2021-07-15 17:05:36
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.