diff --git a/modules/@angular/compiler/src/template_parser/template_parser.ts b/modules/@angular/compiler/src/template_parser/template_parser.ts index 10d68d4de1..2b8348b7c9 100644 --- a/modules/@angular/compiler/src/template_parser/template_parser.ts +++ b/modules/@angular/compiler/src/template_parser/template_parser.ts @@ -644,7 +644,11 @@ class TemplateParseVisitor implements html.Visitor { private _assertOnlyOneComponent(directives: DirectiveAst[], sourceSpan: ParseSourceSpan) { const componentTypeNames = this._findComponentDirectiveNames(directives); if (componentTypeNames.length > 1) { - this._reportError(`More than one component: ${componentTypeNames.join(',')}`, sourceSpan); + this._reportError( + `More than one component matched on this element.\n` + + `Make sure that only one component's selector can match a given element.\n` + + `Conflicting components: ${componentTypeNames.join(',')}`, + sourceSpan); } } @@ -831,4 +835,4 @@ const NON_BINDABLE_VISITOR = new NonBindableVisitor(); function _isEmptyTextNode(node: html.Node): boolean { return node instanceof html.Text && node.value.trim().length == 0; -} \ No newline at end of file +} 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 6b32b3c154..8cb15dee05 100644 --- a/modules/@angular/compiler/test/template_parser/template_parser_spec.ts +++ b/modules/@angular/compiler/test/template_parser/template_parser_spec.ts @@ -1495,8 +1495,12 @@ Parser Error: Unexpected token 'b' at column 3 in [a b] in TestComp@0:5 ("
}), template: new CompileTemplateMetadata({ngContentSelectors: []}) }); - expect(() => parse('
', [dirB, dirA])).toThrowError(`Template parse errors: -More than one component: DirB,DirA ("[ERROR ->]
"): TestComp@0:0`); + expect(() => parse('
', [dirB, dirA])) + .toThrowError( + `Template parse errors:\n` + + `More than one component matched on this element.\n` + + `Make sure that only one component's selector can match a given element.\n` + + `Conflicting components: DirB,DirA ("[ERROR ->]
"): TestComp@0:0`); }); it('should not allow components or element bindings nor dom events on explicit embedded templates',