Reputation: 326
After migrate to Angular 9 (before was Angular 8), i get a problem with using some own component. My component choose-popup-data-reference have module (declare and export), which is imported in docName module. But I get ERROR. (I try add CUSTOM_ELEMENTS_SCHEMA, but it doesn't help).
I use this component in other modules, and everything work well.
ERROR in src/app/components/feature/document/docName.html:211:1 - error NG8001: 'choose-popup-data-
reference' is not a known element:
1. If 'choose-popup-data-reference' is an Angular component, then verify that it is part of this module.
2. If 'choose-popup-data-reference' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
211 <choose-popup-data-reference
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212 [referenceType]="'some_type'"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213 #docComplModal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214 (setChooseData)="fillDocAction($event)">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module for component - choose-popup-data-reference
@NgModule({
imports: [CommonModule, TranslateModule, FormsModule],
exports: [ChoosePopupDataReferenceComponent],
declarations: [ChoosePopupDataReferenceComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class ChoosePopupDataReferenceModule {
}
After import in imports block docNameModule
...
imports: [
...
ChoosePopupDataReferenceModule
...
]
...
Upvotes: 3
Views: 4885
Reputation: 37
You have to add NO_ERRORS_SCHEMA as well along with CUSTOM_ELEMENTS_SCHEMA in schemas. After that stop and run command ng serve or npm start. It will work surely.
Upvotes: -2
Reputation: 2289
ERROR in src/app/<your-template>.html:64:5 - error NG8001: 'your-component' is not a known element:
Check which module the parent component is being declared in because in my case the parent component was being declared in the shared module of our Angular project. It turned out my child component required to be in declared in the shared module along with the parent to make this work. I took my component out of the module declarations that Angular CLI put it in and put it in the declarations of the shared module and it works.
Key thing is: I used the Angular CLI to generate my component but the CLI added the component to the wrong module declarations, however the Angular CLI wasn't totally wrong to do this as it was actually the logical file directory for the component and the logical module for the component.
In my case the parent component was being used as a routing component. It may turn out that my parent component needs it's own NgModule but I'm not sure yet.
Upvotes: 3
Reputation: 326
My docNameModule has not been used anywhere. (Old page unused, but not delete). After I import module to SubModule (lazy) the error disappeared.
Upvotes: 1