繁体   English   中英

Angular:未捕获错误:组件 BucketGridComponent 不是任何 NgModule 的一部分,或者该模块尚未导入您的模块

[英]Angular: Uncaught Error: Component BucketGridComponent is not part of any NgModule or the module has not been imported into your module

我在向我的应用程序添加组件时遇到了问题。 根据我到目前为止阅读和看到的内容,Angular 将在启动时加载所有 xx.module.ts 文件。 所以我有一个 app.module.ts 包含主要内容,但现在我有一个名为 bucket-grid.component 的组件,我想在我的应用程序中使用它。 为此,我创建了一个 bucket-grid.module.ts 以便我可以在我的路线等中访问它。

这是模块的样子:

import { NgModule } from '@angular/core';
import { IgxListModule, IgxExpansionPanelModule } from 'igniteui-angular';
import { FilterModule } from '../../modules/filter/filter.module';
import { BucketGridComponent } from './components/bucket-grid/bucket-grid.component';


@NgModule({
  declarations: [
    BucketGridComponent
  ],
  imports: [
    IgxListModule,
    IgxExpansionPanelModule,
    FilterModule,
    ],
  exports: [
    BucketGridComponent,

  ],
})
export class BucketGridModule { }

当我启动我的应用程序时,我收到错误:

未捕获的错误:组件 BucketGridComponent 不是任何 NgModule 的一部分,或者该模块尚未导入到您的模块中。

有什么我想念的吗? 我需要在某处注册模块吗?

您确实需要在某处“注册”该模块。 您必须将 BucketGridModule 作为import添加到您的 app.module.ts 文件中。 AppModule 是应用程序的根模块。 您的其他模块应该由这个导入。

 @NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    BucketGridModule
    ],
  exports: [
    ...
  ],
})
export class AppModule { }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM