Shoaib Iqbal
Shoaib Iqbal

Reputation: 1178

Angular 6: Template parse errors: 'component' is not a known element

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:

  1. Adding RegisteryTableComponent to entryComponents in app.module.ts.
  2. Added RegisteryTableComponent to exports array in app.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.

Upvotes: 1

Views: 5579

Answers (2)

Vishal Hasnani
Vishal Hasnani

Reputation: 728

Change selector in registry-table.component.ts from 'registery-table' to this 'registry-table'

Upvotes: 2

Joe Keene
Joe Keene

Reputation: 2351

Looks like you've typo'd the selector change registery-table to registry-table

Upvotes: 3

Related Questions