docs(common): update ngFor docs to new `as` syntax (#15166)

This commit is contained in:
Josep Sayol 2017-03-23 01:18:22 +01:00 committed by Igor Minar
parent 26f6bd4d3b
commit 9319b5f329
3 changed files with 5 additions and 6 deletions

View File

@ -45,7 +45,7 @@ export class NgForOfContext<T> {
* - `odd: boolean`: True when the item has an odd index in the iterable. * - `odd: boolean`: True when the item has an odd index in the iterable.
* *
* ``` * ```
* <li *ngFor="let user of userObservable | async as users; indexes as i; first as isFirst"> * <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
* {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span> * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
* </li> * </li>
* ``` * ```
@ -78,8 +78,8 @@ export class NgForOfContext<T> {
* *
* ### Syntax * ### Syntax
* *
* - `<li *ngFor="let item of items; let i = index; trackBy: trackByFn">...</li>` * - `<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>`
* - `<li template="ngFor let item of items; let i = index; trackBy: trackByFn">...</li>` * - `<li template="ngFor let item of items; index as i; trackBy: trackByFn">...</li>`
* *
* With `<ng-template>` element: * With `<ng-template>` element:
* *

View File

@ -16,7 +16,7 @@ import {FormArray, FormControl, FormGroup} from '@angular/forms';
template: ` template: `
<form [formGroup]="form" (ngSubmit)="onSubmit()"> <form [formGroup]="form" (ngSubmit)="onSubmit()">
<div formArrayName="cities"> <div formArrayName="cities">
<div *ngFor="let city of cities.controls; let i=index"> <div *ngFor="let city of cities.controls; index as i">
<input [formControlName]="i" placeholder="City"> <input [formControlName]="i" placeholder="City">
</div> </div>
</div> </div>

View File

@ -34,7 +34,7 @@ export const FormErrorExamples = {
formArrayName: ` formArrayName: `
<div [formGroup]="myGroup"> <div [formGroup]="myGroup">
<div formArrayName="cities"> <div formArrayName="cities">
<div *ngFor="let city of cityArray.controls; let i=index"> <div *ngFor="let city of cityArray.controls; index as i">
<input [formControlName]="i"> <input [formControlName]="i">
</div> </div>
</div> </div>
@ -61,4 +61,3 @@ export const FormErrorExamples = {
</div> </div>
` `
}; };