I am trying to use a component selector in another component but it shows an error.
Uncaught Error: Template parse errors:
'registryTable' is not a known element:
1. If 'registryTable' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("[ERROR ->]<registryTable></registryTable>"):
I have tried adding it to app.module.ts but it still throws that error.
here is part of code I am using.
app.module.ts
import { RegisteryComponent } from './registery/registery.component';
import { RegisteryTableComponent } from './registery/registry-table/registery-table.component';
@NgModule({
declarations: [
AppComponent,
RegisteryComponent,
RegisteryTableComponent
],
imports: [
...
],
exports: [
CdkTableModule,
CdkTreeModule
],
providers: [...],
entryComponents: [],
bootstrap: [AppComponent]
})
export class AppModule { }
registry.component.ts
import { Component, OnInit, ViewChild } from '@angular/core';
import { RegisteryTableComponent } from './registry-table/registery-table.component';
@Component({
selector: 'app-registery',
template: '<registry-table></registry-table>',
styleUrls: ['./registery.component.scss']
})
export class RegisteryComponent implements OnInit {
@ViewChild(RegisteryTableComponent) registeryTable: RegisteryTableComponent;
constructor() { }
ngOnInit() { }
}
registry-table.component.ts
import { Component, OnInit, ViewChild, Input } from '@angular/core';
@Component({
selector: 'registery-table',
templateUrl: './registery-table.component.html',
styleUrls: ['./registery-table.component.scss']
})
export class RegisteryTableComponent implements OnInit {
constructor() { }
ngOnInit() {}
}
What I have already tried:
- Adding
RegisteryTableComponenttoentryComponentsinapp.module.ts. - Added
RegisteryTableComponenttoexportsarray inapp.module.ts
I have tried most of the solutions found for similar error but none of them worked for me. Any help would be highly appreciated.
registryTableComponentis not part of any module, instead it is part of root module.