其他分享
首页 > 其他分享> > Component Xxx is not part of any NgModule or the module has not been imported into your module.

Component Xxx is not part of any NgModule or the module has not been imported into your module.

作者:互联网

原文链接:这里

0.背景

调试angular项目时,报这个错。子组件的引用是正确的,可是还是报这个错误。

组件是使用ng g m创建的。

1.解决办法

查看你的xxx.module.ts中是否正确引用了子组件。正确的做法是:

import { NgModule } from '@angular/core'; import { ListComponent } from './list/list.component';   @NgModule({ declarations: [ListComponent], imports: [ xxxxRoutingModule ], exports: [ListComponent], })

先使用import导入组件,然后在declarations中和exports 写组件的名字。

 

标签:ListComponent,exports,imported,into,module,NgModule,组件,import
来源: https://www.cnblogs.com/longkui-site/p/15859512.html