很快,为了在一个懒惰模块中移动一些逻辑和组件,您可以运行以下命令:
ng g module child --routing
然后angular-cli将生成一个NgModule(app / child / child.module.ts)和一个子路由器配置(app / child / child-routing.module.ts).
延迟加载此子路由器的路由将是:
{ path: 'child', loadChildren: 'app/child/child.module#ChildModule' }
最后用一个约束移动你想要的ChildModule:其他模块(作为AppModule)将无法使用任何ChildModule依赖项(例如服务).如果你需要它,一个很好的做法是创建一个共享模块.
http://stackoverflow.com/questions/39619003/creating-multiple-bundles-using-angular-cli-webpack