The ngFor directive - FadiZahhar/switchingtoangular2 GitHub Wiki

you can find the sample code of ngfor on the app/ch4/ng-for.

The ngFor directive is a directive that allows us to loop over a collection of items and does exactly what ng-repeat does in AngularJS 1.x, but it brings some extra semantics. Note that the ngForOf attribute is surrounded by brackets. At first, these brackets might seem like invalid HTML. However, according to the HTML specification, their use is permitted in attribute names. The only thing the W3C validator is going to complain about is the fact that the template element doesn't own such attributes; however, browsers won't have problems processing the markup. The semantics behind these brackets is that the value of the attribute surrounded by them is an expression, which needs to be evaluated.

Angular provides alternative canonical syntax, which allows us to define the bindings of the elements without using brackets. For instance, the property binding can be expressed using the following code: <input [value]="foo"> It can also be expressed using this: Similarly, we can express the event bindings with the following code: <button (click)="handle()">Click me They can also be expressed using this: Click me

Angular provides alternative canonical syntax, which allows us to define the bindings of the elements without using brackets. For instance, the property binding can be expressed using the following code: <input [value]="foo"> It can also be expressed using this: Similarly, we can express the event bindings with the following code: <button (click)="handle()">Click me They can also be expressed using this: Click me

⚠️ **GitHub.com Fallback** ⚠️