我有一個應用程序,其中包含2個模塊:「Shared」和「Web」。Angular:來自共享模塊的組件不被識別
我在網絡中的所有組件都正常工作。我剛剛創建的共享模塊中的一個簡單的組件,因爲我打算重新使用它整個應用程序:
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'pb-ds-pluginstable',
templateUrl: './pluginstable.component.html',
styleUrls: ['./pluginstable.component.scss']
})
export class PluginstableComponent implements OnInit {
@Input() name: string;
@Input() version: string;
@Input() link: string;
constructor() {}
ngOnInit() {}
}
這是導入共享模塊,並遠銷:
...other imports...
import { PluginstableComponent } from './pluginstable/pluginstable.component';
@NgModule({
imports: [
CommonModule,
RouterModule,
NgbModule
],
declarations: [HeaderComponent, FooterComponent, HeaderShadowDirective, PluginstableComponent],
exports: [HeaderComponent, FooterComponent, HeaderShadowDirective, PluginstableComponent]
})
export class SharedModule { }
但我當在Web模塊中使用的組件的模板,像這樣:
<pb-ds-pluginstable name="foo" version="2.2.2" link="bar"></pb-ds-pluginstable>
我得到的組件不識別的錯誤:
core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Template parse errors:
'pb-ds-pluginstable' is not a known element:
1. If 'pb-ds-pluginstable' is an Angular component, then verify that it is part of this module.
2. If 'pb-ds-pluginstable' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
</section>
[ERROR ->]<pb-ds-pluginstable name="foo" version="2.2.2" link="bar"></pb-ds-pluginstable>
我在這裏錯過了什麼?
並且您的共享模塊導入到應用程序/根模塊中? – Brandon
是的,它是...... – Steve
嗯。我見過Angular要求我在添加共享模塊時停止我的開發服務器並重新構建項目。我有一個奇怪的緩存問題,有一天刪除的界面掛在...你有沒有嘗試重新啓動你的IDE? – Brandon