typescript “模块”不是任何 NgModule 的一部分,或者该模块尚未导入到您的模块中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40638115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Module" is not part of any NgModule or the module has not been imported into your module
提问by dev_054
I have an application with some modules.
我有一个带有一些模块的应用程序。
Here is my root module:
这是我的根模块:
// imports...
@NgModule({
bootstrap: [ AppModule ],
declarations: [
AppComponent,
...APP_PIPES // Array with my pipes
],
imports: [ // import Angular's modules
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
RouterModule.forRoot(ROUTES),
...APP_MODULES, // Array with my modules
...THIRD_PARTY_MODULES // Array with libs modules
],
providers: [ // expose our Services and Providers into Angular's dependency injection
ENV_PROVIDERS,
APP_PROVIDERS
]
})
export class AppModule {
...
}
And here's ONEof my commonmodules:
而这里的ONE的我的共同模块:
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MenuComponent } from './menu.component';
@NgModule({
declarations: [ MenuComponent ],
exports: [ MenuComponent ],
imports: [ CommonModule ],
providers: [ ]
})
export class MenuModule {
...
}
I thought it's the correct way to do this, however I'm getting the following error:
我认为这是正确的方法,但是我收到以下错误:
AppModule is not part of any NgModule or the module has not been imported into your module
AppModule 不是任何 NgModule 的一部分,或者该模块尚未导入到您的模块中
I searched for AppModule in my whole application and I'm using only it in my app.module.ts
.
我在整个应用程序中搜索了 AppModule 并且我只在我的app.module.ts
.
Am I missing to import/export something? Any help would be great. Thanks.
我是否缺少导入/导出某些东西?任何帮助都会很棒。谢谢。
回答by Günter Z?chbauer
This
这
bootstrap: [ AppModule ],
should be
应该
bootstrap: [ AppComponent ],
Here you need to pass the AppModule
在这里你需要通过 AppModule
platformBrowserDynamic().bootstrapModule(AppModule);