在我的主要組件的html模板中,我使用了我導入的模塊中的組件的元素。當我試圖建立這個時,我得到以下錯誤。Angular CLI生成版本,未知元素
'df-dashboard-widget' is not a known element:
1. If 'df-dashboard-widget' is an Angular component, then verify that it is part of this module.
2. If 'df-dashboard-widget' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
而且也是這個錯誤:
ERROR in Template parse errors:
Can't bind to 'options' since it isn't a known property of 'df-dashboard-grid'.
1. If 'df-dashboard-grid' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'df-dashboard-grid' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
我的HTML模板看起來是這樣的:
<df-dashboard-grid [options]="options">
<df-dashboard-widget [item]="item" *ngFor="let item of dashboard">
<ng-container *ngComponentOutlet="getComponent(item.tag); injector: getProvider(item)"></ng-container>
</df-dashboard-widget>
</df-dashboard-grid>
我已導入具有df-dashboard-grid
部件內置模塊,這部分是導出的。同樣的問題發生在。還有一個錯誤說雖然我已經從Angular導入CommonModule
,但ngComponentOutlet
不是ng-container
的屬性。我的主要模塊的裝飾看起來是這樣的:
@NgModule({
declarations: [
DashboardComponent
],
imports: [
BrowserModule,
CommonModule,
HttpModule,
DashboardGridModule
].concat(Configuration.initialization.modules),
providers: [],
bootstrap: [DashboardComponent]
})
與組件裝飾所使用的模塊如下所示:
@NgModule({
declarations: [
DashboardGridComponent,
DashboardWidgetComponent,
DashboardGuideComponent,
DashboardPreviewComponent
],
imports: [
CommonModule
],
exports: [DashboardGridComponent, DashboardWidgetComponent],
})
該錯誤僅發生在生產模式時。在開發模式下,一切工作正常。
導出所有組件 – alehn96