问题描述
eRROR
Error: Uncaught (in promise): Error: Template parse errors:
'app-customer-list' is not a kNown element:
1. If 'app-customer-list' is an Angular component,then verify that it is part of this module.
2. If 'app-customer-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
</p>
https://stackblitz.com/edit/angular-zkciqv?file=src/app/orders/order-list/order-list.component.html
检查组件: 订单 -> 订单列表 -> Order.component.html
解决方法
首先在您的客户模块中,您需要使用 export
属性将 exports
个组件公开给其他模块:
customers.module.ts
@NgModule({
imports: [
CommonModule,CustomersRoutingModule
],declarations: [CustomerListComponent],exports: [CustomerListComponent]
})
export class CustomersModule { }
接下来,您需要将 import
CustomersModule
放入将使用该模块导出的组件的模块中:
orders.module.ts
@NgModule({
imports: [
CommonModule,OrdersRoutingModule,CustomersModule
],declarations: [OrderListComponent]
})
export class OrdersModule { }