我正在角度4中实现一个超级应用程序,它将加载子应用程序模块(组件和路由) . 子应用程序托管在http://child-application-url上 . 如何在我的超级应用程序中延迟加载子模块?
{path:'child-module-path',loadChildren:'http://child-application-url/main.js#ChildModule'}
这些是我的依赖
"dependencies": {
"@angular-redux/store": "^6.1.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "^0.0.3",
"@types/hammerjs": "^2.0.34",
"body-parser": "^1.17.1",
"core-js": "^2.4.1",
"express": "^4.15.2",
"hammerjs": "^2.0.8",
"redux": "^3.6.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
儿童申请:
新的儿童应用程序
创建一个新的功能模块'child'并将其延迟加载到child-app中
{ path: 'module1', loadChildren: 'app/child/child.module#ChildModule', }
ng构建并在节点服务器上的端口4202上运行
超级应用:
新的超级应用程序
在尝试懒洋洋地加载子应用程序模块时遇到问题
{ path: 'child-module-path', loadChildren: 'http://child-application-url/main.js#ChildModule' }