-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
In my application , lazy loading was perfectly working in Angular 4 and 5 . However , after I migrated to Angular 6 , the lazy loading and routing has stopped working when I use ng serve.
The routes for the application are defined in app.module.ts
like this :
RouterModule.forRoot([
{ path: 'info/:gitCode/:pemCode/:getRtComponent', component: RedComponent },
{ path: 'info/:gitCode/:pemCode/:getFaq/:getRtComponent', component: RedComponent },
{ path: 'loadGuardsInfo/:gitCode/:pemCode/:getRtComponent', component: RedComponent },
{ path: 'loadGuardsInfo/:getRtComponent', component: RedComponent },
{ path: 'recDet', component: RecDetComponent },
{ path: 'SlaveComponent/:pfScreen', loadChildren: './ally/slave/slave.module#SlaveModule' },
{ path: 'MasterComponent/:pfScreen', loadChildren: './ally/master/master.module#MasterModule' },
{ path: 'DashedComponent/:pfScreen', loadChildren: './ally/dashed/dashed.module#DashedModule' }
])
],
providers: [ReqService, { provide: APP_BASE_HREF, useValue: './' }, {
provide: ErrorHandler,
useClass: GlobalErrorHandler
}, { provide: LocationStrategy, useClass: HashLocationStrategy }],
bootstrap: [AppComponent],
exports: []
I have gone through a lot of articles on the internet about this and tried out a lot of things , but none worked . While migrating from angular 5 to 6, a lot of configurations in the old code got changed like : angular-cli.json
got changed to angular.json
. Lot of packages in package.json
got upgraded and 2 new packages got introduced : @angular-devkit/build-angular
and rxjs-compat
. The package : @angular-devkit/build-angular
seems to be utilized by the angular.json
for build and serve . I am not understanding why the migration has broken the routing and lazy loading .
Can someone please help me out here ?
My Package.json
dependencies are listed below :
"dependencies": {
"@angular/animations": "^6.1.10",
"@angular/common": "^6.1.10",
"@angular/compiler": "^6.1.10",
"@angular/core": "^6.1.10",
"@angular/forms": "^6.1.10",
"@angular/http": "^6.1.10",
"@angular/platform-browser": "^6.1.10",
"@angular/platform-browser-dynamic": "^6.1.10",
"@angular/platform-server": "^6.1.10",
"@angular/router": "^6.1.10",
"@ng-idle/core": "^6.0.0-beta.5",
"@ng-idle/keepalive": "^6.0.0-beta.5",
"ag-grid": "14.2.0",
"ag-grid-angular": "14.2.0",
"angular-polyfills": "1.0.1",
"angular2-uuid": "1.1.1",
"bootstrap": "3.3.7",
"core-js": "2.5.3",
"exceljs": "1.0.0",
"file-saver": "1.3.3",
"font-awesome": "4.7.0",
"http-proxy": "1.16.2",
"primeng": "4.3.0",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.2.0",
"ts-helpers": "1.1.2",
"xlsx": "0.10.9",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "^6.2.9",
"@angular/compiler-cli": "^6.1.10",
"@types/jasmine": "2.8.6",
"@types/node": "7.0.57",
"@types/systemjs": "0.20.6",
"codelyzer": "^6.0.0",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.2.1",
"jquery": "3.3.1",
"jquery-ui": "1.12.1",
"karma": "1.3.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-html-reporter": "0.1.3",
"karma-htmlfile-reporter": "0.3.5",
"karma-jasmine": "1.1.1",
"karma-remap-istanbul": "0.2.2",
"karma-story-reporter": "0.3.1",
"protractor": "4.0.14",
"ts-node": "3.0.4",
"tslint": "5.9.1",
"typescript": "^2.7.2"
}