@@ -41,8 +41,12 @@ export interface DomSchemaChecker {
4141 * @param element the element node in question.
4242 * @param schemas any active schemas for the template, which might affect the validity of the
4343 * element.
44+ * @param hostIsStandalone boolean indicating whether the element's host is a standalone
45+ * component.
4446 */
45- checkElement ( id : string , element : TmplAstElement , schemas : SchemaMetadata [ ] ) : void ;
47+ checkElement (
48+ id : string , element : TmplAstElement , schemas : SchemaMetadata [ ] ,
49+ hostIsStandalone : boolean ) : void ;
4650
4751 /**
4852 * Check a property binding on an element and record any diagnostics about it.
@@ -73,7 +77,9 @@ export class RegistryDomSchemaChecker implements DomSchemaChecker {
7377
7478 constructor ( private resolver : TemplateSourceResolver ) { }
7579
76- checkElement ( id : TemplateId , element : TmplAstElement , schemas : SchemaMetadata [ ] ) : void {
80+ checkElement (
81+ id : TemplateId , element : TmplAstElement , schemas : SchemaMetadata [ ] ,
82+ hostIsStandalone : boolean ) : void {
7783 // HTML elements inside an SVG `foreignObject` are declared in the `xhtml` namespace.
7884 // We need to strip it before handing it over to the registry because all HTML tag names
7985 // in the registry are without a namespace.
@@ -82,15 +88,17 @@ export class RegistryDomSchemaChecker implements DomSchemaChecker {
8288 if ( ! REGISTRY . hasElement ( name , schemas ) ) {
8389 const mapping = this . resolver . getSourceMapping ( id ) ;
8490
91+ const schemas = `'${ hostIsStandalone ? '@Component' : '@NgModule' } .schemas'` ;
8592 let errorMsg = `'${ name } ' is not a known element:\n` ;
86- errorMsg +=
87- `1. If '${ name } ' is an Angular component, then verify that it is part of this module.\n` ;
93+ errorMsg += `1. If '${ name } ' is an Angular component, then verify that it is ${
94+ hostIsStandalone ? 'included in the \'@Component.imports\' of this component' :
95+ 'part of this module' } .\n`;
8896 if ( name . indexOf ( '-' ) > - 1 ) {
89- errorMsg += `2. If '${
90- name } ' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule. schemas' of this component to suppress this message.`;
97+ errorMsg += `2. If '${ name } ' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${
98+ schemas } of this component to suppress this message.`;
9199 } else {
92100 errorMsg +=
93- `2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule. schemas' of this component.` ;
101+ `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${ schemas } of this component.` ;
94102 }
95103
96104 const diag = makeTemplateDiagnostic (
0 commit comments