feat(ivy): Bind to right context in nested template statmentes (#23168)

Given
```
<div *ngFor=”…” (click)=“doSomething()”>
```

Before `doSomething` would execute on the inner template context, which
is incorrect. The correct behavior is to execute on the top level context
of the component.

PR Close #23168
This commit is contained in:
Miško Hevery
2018-04-03 15:46:16 -07:00
committed by Igor Minar
parent c059670792
commit f544635014
2 changed files with 98 additions and 1 deletions

View File

@ -641,7 +641,7 @@ class TemplateDefinitionBuilder implements TemplateAstVisitor, LocalResolver {
element.outputs.forEach((outputAst: BoundEventAst) => {
const functionName = `${this.templateName}_${element.name}_${outputAst.name}_listener`;
const bindingExpr = convertActionBinding(
this, implicit, outputAst.handler, 'b', () => error('Unexpected interpolation'));
this, o.variable('ctx'), outputAst.handler, 'b', () => error('Unexpected interpolation'));
const handler = o.fn(
[new o.FnParam('$event', o.DYNAMIC_TYPE)],
[...bindingExpr.stmts, new o.ReturnStatement(bindingExpr.allowDefault)], o.INFERRED_TYPE,