我有一个角度模块,其中包含两个组件。
第一个组件是这样定义的。
overview.component.ts
@Component({
selector: 'app-pricing-table',
templateUrl: './pricing-table.component.html',
styleUrls: ['./pricing-table.component.scss']
})
export class PricingTableComponent implements OnInit {
}
在第二个组件中,我尝试使用给定的标记包括概述组件。
<app-pricing-table></app-pricing-table>
这两个组件都在同一模块中定义。
@NgModule({
declarations: [OverviewComponent, PricingTableComponent],
imports: [
CommonModule,
SubscriptionRoutingModule,
],
})
export class SubscriptionModule { }
When I run ng serve
I get an error. I`ve restarted the development server multiple times.
ERROR in src/app/modules/subscription/pages/overview/overview.component.html:13:1 - error NG8001: 'app-pricing-table' is not a known element:
1. If 'app-pricing-table' is an Angular component, then verify that it is part of this module.
2. If 'app-pricing-table' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
13 <app-pricing-table></app-pricing-table>
src/app/modules/subscription/pages/overview/overview.component.ts:5:16
5 templateUrl: './overview.component.html',
Error occurs in the template of component OverviewComponent.
我的模块/组件有什么问题?
You have to export the components from the module which you have created and mention them in
exports:[ ]