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:

committed by
Chuck Jazdzewski

parent
5fe2d8fd80
commit
c10c060d20
@ -429,6 +429,16 @@ export function main() {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should support as notation', () => {
|
||||
let bindings = parseTemplateBindings('ngIf exp as local', 'location');
|
||||
expect(keyValues(bindings)).toEqual(['ngIf=exp in location', 'let local=ngIf']);
|
||||
|
||||
bindings = parseTemplateBindings('ngFor let item of items as iter; index as i', 'L');
|
||||
expect(keyValues(bindings)).toEqual([
|
||||
'ngFor', 'let item=$implicit', 'ngForOf=items in L', 'let iter=ngForOf', 'let i=index'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should parse pipes', () => {
|
||||
const bindings = parseTemplateBindings('key value|pipe');
|
||||
const ast = bindings[0].expression.ast;
|
||||
|
Reference in New Issue
Block a user