Tutorial by Examples

<ul> <li *ngFor="let item of items">{{item.name}}</li> </ul>
<div *ngFor="let item of items"> <p>{{item.name}}</p> <p>{{item.price}}</p> <p>{{item.description}}</p> </div>
<div *ngFor="let item of items; let i = index"> <p>Item number: {{i}}</p> </div> In this case, i will take the value of index, which is the current loop iteration.
Angular2 provides several exported values that can be aliased to local variables. These are: index first last even odd Except index, the other ones take a Boolean value. As the previous example using index, it can be used any of these exported values: <div *ngFor="let item of item...
import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'even' }) export class EvenPipe implements PipeTransform { transform(value: string): string { if(value && value %2 === 0){ return value; } } } @Component({ selector: '...

Page 1 of 1