fix(view): local variables override local variables set by ng-for
This commit is contained in:
@@ -541,6 +541,24 @@ export function main() {
|
||||
expect(view.rawView.locals).not.toBe(null);
|
||||
expect(view.rawView.locals.get('superAlice')).toBeAnInstanceOf(ChildComp);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow to use variables in a for loop',
|
||||
inject([TestBed, AsyncTestCompleter], (tb: TestBed, async) => {
|
||||
tb.overrideView(MyComp, new viewAnn.View({
|
||||
template:
|
||||
'<div><div *ng-for="var i of [1]"><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</div></div>',
|
||||
directives: [ChildCompNoTemplate, NgFor]
|
||||
}));
|
||||
|
||||
tb.createView(MyComp, {context: ctx})
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
||||
expect(view.rootNodes).toHaveText("1-hello");
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -1343,6 +1361,13 @@ class ChildComp {
|
||||
}
|
||||
}
|
||||
|
||||
@Component({selector: 'child-cmp-no-template'})
|
||||
@View({directives: [], template: ''})
|
||||
@Injectable()
|
||||
class ChildCompNoTemplate {
|
||||
ctxProp: string = 'hello';
|
||||
}
|
||||
|
||||
@Component({selector: 'child-cmp-svc'})
|
||||
@View({template: '{{ctxProp}}'})
|
||||
@Injectable()
|
||||
|
||||
Reference in New Issue
Block a user