Angular 2 : No NgModule metadata found

后端 未结 28 1462
盖世英雄少女心
盖世英雄少女心 2020-11-30 05:31

I\'m brand new to Angular 2 and attempting to follow along with a video tutorial I found. Despite following all of the steps, Angular just won\'t work; I get the following e

28条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 05:51

    If Nothing else works try following

    if (environment.production) {
            // there is no need of this if block, angular internally creates following code structure when it sees --prod
            // but at the time of writting this code, else block was not working in the production mode and NgModule metadata
            // not found for AppModule error was coming at run time, added follow code to fix that, it can be removed probably 
            // when angular is upgraded to latest version or if it start working automatically. :)
            // we could also avoid else block but building without --prod saves time in building app locally.
            platformBrowser(extraProviders).bootstrapModuleFactory(AppModuleNgFactory);
        } else {
            platformBrowserDynamic(extraProviders).bootstrapModule(AppModule);
        }
    

提交回复
热议问题