我正在尝试在另一个组件中使用组件选择器,但是它显示错误。
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>"):
我尝试将其添加到app.module.ts
,但仍然会引发该错误。
这是我正在使用的代码的一部分。
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() {}
}
我已经尝试过的:
RegisteryTableComponent
添加到entryComponents
中。app.module.ts
中的RegisteryTableComponent
数组中添加了exports
我尝试了针对类似错误找到的大多数解决方案,但没有一个对我有用。 任何帮助将不胜感激。
答案 0 :(得分:0)
好像您将选择器的错字由registery-table
更改为registry-table
答案 1 :(得分:0)
更改registry-table.component.ts中的选择器 从“注册表”到“注册表”