diff --git a/packages/compiler/src/render3/r3_view_compiler.ts b/packages/compiler/src/render3/r3_view_compiler.ts index 610cb3d31a..35357b0637 100644 --- a/packages/compiler/src/render3/r3_view_compiler.ts +++ b/packages/compiler/src/render3/r3_view_compiler.ts @@ -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, diff --git a/packages/compiler/test/render3/r3_view_compiler_template_spec.ts b/packages/compiler/test/render3/r3_view_compiler_template_spec.ts new file mode 100644 index 0000000000..6e38b1d6c0 --- /dev/null +++ b/packages/compiler/test/render3/r3_view_compiler_template_spec.ts @@ -0,0 +1,97 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {MockDirectory, setup} from '../aot/test_util'; +import {compile, expectEmit} from './mock_compile'; + +/* These tests are codified version of the tests in compiler_canonical_spec.ts. Every + * test in compiler_canonical_spec.ts should have a corresponding test here. + */ +describe('compiler compliance: listen()', () => { + const angularFiles = setup({ + compileAngular: true, + compileAnimations: false, + compileCommon: true, + }); + + it('should create correctly bind to context in nested template', () => { + const files = { + app: { + 'spec.ts': ` + import {Component, NgModule} from '@angular/core'; + import {CommonModule} from '@angular/common'; + + @Component({ + selector: 'my-component', + template: \` +