feat(common): support as syntax in template/* bindings (#15025)

* feat(common): support `as` syntax in template/* bindings

Closes #15020

Showing the new and the equivalent old syntax.
- `*ngIf="exp as var1”`
   => `*ngIf="exp; let var1 = ngIf”`
- `*ngFor="var item of itemsStream |async as items”`
   => `*ngFor="var item of itemsStream |async; let items = ngForOf”`

* feat(common): convert ngIf to use `*ngIf="exp as local“` syntax

* feat(common): convert ngForOf to use `*ngFor=“let i of exp as local“` syntax

* feat(common): expose NgForOfContext and NgIfContext
This commit is contained in:
Miško Hevery
2017-03-14 20:46:29 -07:00
committed by Chuck Jazdzewski
parent 5fe2d8fd80
commit c10c060d20
12 changed files with 137 additions and 35 deletions

View File

@ -151,13 +151,26 @@ export declare const NgFor: typeof NgForOf;
/** @stable */
export declare class NgForOf<T> implements DoCheck, OnChanges {
ngForOf: NgIterable<T>;
ngForTemplate: TemplateRef<NgForOfRow<T>>;
ngForTemplate: TemplateRef<NgForOfContext<T>>;
ngForTrackBy: TrackByFunction<T>;
constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<NgForOfRow<T>>, _differs: IterableDiffers);
constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<NgForOfContext<T>>, _differs: IterableDiffers);
ngDoCheck(): void;
ngOnChanges(changes: SimpleChanges): void;
}
/** @stable */
export declare class NgForOfContext<T> {
$implicit: T;
count: number;
readonly even: boolean;
readonly first: boolean;
index: number;
readonly last: boolean;
ngForOf: NgIterable<T>;
readonly odd: boolean;
constructor($implicit: T, ngForOf: NgIterable<T>, index: number, count: number);
}
/** @stable */
export declare class NgIf {
ngIf: any;
@ -166,6 +179,12 @@ export declare class NgIf {
constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<NgIfContext>);
}
/** @stable */
export declare class NgIfContext {
$implicit: any;
ngIf: any;
}
/** @experimental */
export declare class NgLocaleLocalization extends NgLocalization {
protected locale: string;