1

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.

4
  • This seems that your registry table component is in another module. Are you using 2 or more modules in your project? Commented Jan 15, 2019 at 9:38
  • No, its not in another module, there are multiple modules but registryTableComponent is not part of any module, instead it is part of root module. Commented Jan 15, 2019 at 9:41
  • You made a typo mistake while rendering selector Commented Jan 15, 2019 at 9:46
  • @SnehaPawar yes it was typo, thank you Commented Jan 15, 2019 at 9:52

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Can't believe it was a spelling issue.
Happens to the best of us buddy, one always thinks it's something more complicated :)
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.