From 213c713409fff9d0ac45e7f4f183a9207760c9a2 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 7 Dec 2016 21:38:52 -0800 Subject: [PATCH] fix: Better error when directive not listed in NgModule.declarations --- .../compiler/src/template_parser/template_parser.ts | 4 ++-- .../compiler/test/template_parser/template_parser_spec.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/@angular/compiler/src/template_parser/template_parser.ts b/modules/@angular/compiler/src/template_parser/template_parser.ts index a89a776692..893ce2212f 100644 --- a/modules/@angular/compiler/src/template_parser/template_parser.ts +++ b/modules/@angular/compiler/src/template_parser/template_parser.ts @@ -685,7 +685,7 @@ class TemplateParseVisitor implements html.Visitor { } elementProps.forEach(prop => { this._reportError( - `Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section.`, + `Property binding ${prop.name} not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations".`, sourceSpan); }); } @@ -704,7 +704,7 @@ class TemplateParseVisitor implements html.Visitor { events.forEach(event => { if (isPresent(event.target) || !allDirectiveEvents.has(event.name)) { this._reportError( - `Event binding ${event.fullName} not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "directives" section.`, + `Event binding ${event.fullName} not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "@NgModule.declarations".`, event.sourceSpan); } }); diff --git a/modules/@angular/compiler/test/template_parser/template_parser_spec.ts b/modules/@angular/compiler/test/template_parser/template_parser_spec.ts index 7ee2bb7d20..b4b0fd4a51 100644 --- a/modules/@angular/compiler/test/template_parser/template_parser_spec.ts +++ b/modules/@angular/compiler/test/template_parser/template_parser_spec.ts @@ -1586,9 +1586,9 @@ Parser Error: Unexpected token 'b' at column 3 in [a b] in TestComp@0:5 ("
parse('', [dirA])) .toThrowError(`Template parse errors: -Event binding e not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "directives" section. (""): TestComp@0:18 +Event binding e not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the "@NgModule.declarations". (""): TestComp@0:18 Components on an embedded template: DirA ("[ERROR ->]"): TestComp@0:0 -Property binding a not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section. ("[ERROR ->]"): TestComp@0:0`); +Property binding a not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("[ERROR ->]"): TestComp@0:0`); }); it('should not allow components or element bindings on inline embedded templates', () => { @@ -1603,7 +1603,7 @@ Property binding a not used by any directive on an embedded template. Make sure .toSummary(); expect(() => parse('
', [dirA])).toThrowError(`Template parse errors: Components on an embedded template: DirA ("[ERROR ->]
"): TestComp@0:0 -Property binding a not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section. ("[ERROR ->]
"): TestComp@0:0`); +Property binding a not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("[ERROR ->]
"): TestComp@0:0`); }); });