angular.io
angular.io copied to clipboard
While using ngUpgrade, does the root module need to have `entryComponents` defined?
I'm using a root ng2 module simply as a means to bootstrap the hybrid application. Then I'm going to add modules to the imports list as I migrate parts of my application over to ng2. Those modules will have entryComponents, but do I need to list any for my root module?
Here's my root module file:
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { UpgradeModule } from "@angular/upgrade/static";
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import NumbersModule from "./numbers/ng2Numbers.module";
@NgModule({
imports: [
BrowserModule,
UpgradeModule,
NumbersModule // one of the migrated modules
],
declarations: [],
entryComponents: [] // Can this be blank? ... and I define entryComponents in `NumbersModule`
})
export default class Ng2AppModule {
ngDoBootstrap() {}
}
platformBrowserDynamic().bootstrapModule(Ng2AppModule).then(platformRef => {
const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
upgrade.bootstrap(document.documentElement, ["app"], {strictDi: true});
});
I'm currently using Angular 2.4.3 for this setup.
Thanks.
Its not required that you have entryComponents in your root module if they are already included in an imported module. All your entryComponents that are imported into your root module will be collected and compiled.
@brandonroberts Thanks for the clarification!