我在角度4中实现了一个超级应用程序,它将加载子应用程序模块(组件和路由)。子应用程序托管在http://child-application-url上。如何在我的超级应用程序中延迟加载子模块?
{ 路径:' 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"
}
儿童申请:
ng new child-app
创建一个新功能模块' child'并延迟将其加载到子应用程序中
{
path: 'module1',
loadChildren: 'app/child/child.module#ChildModule',
}
在节点服务器上的端口4202上构建并运行
超级申请:
ng new super-app
在尝试延迟加载子应用程序模块时遇到问题
{
path: 'child-module-path',
loadChildren: 'http://child-application-url/main.js#ChildModule'
}