2016-11-16 30 views
3

我有一個模塊的應用程序。「模塊」不是任何NgModule的一部分,或者模塊沒有被導入到您的模塊中

這裏是我的根模塊:

// 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 { 
... 
} 

而這裏的我的一個共同模塊

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 { 
    ... 
} 

我認爲這是應該做的正確方法,但我得到以下錯誤:

AppModule is not part of any NgModule or the module has not been imported into your module

我在整個應用程序中搜索了AppModule,並且僅在我的app.module.ts中使用它。

我是否缺少導入/導出內容?任何幫助都會很棒。謝謝。

回答

4

bootstrap: [ AppModule ], 

應該

bootstrap: [ AppComponent ], 

在這裏,你需要通過AppModule

platformBrowserDynamic().bootstrapModule(AppModule); 
+0

非常感謝。這是正確的。 :) –

相關問題