I had working lazy loading in v3 and after updating with v4 it stopped working.
What i have is:
Ionic:
ionic (Ionic CLI) : 4.10.2
Ionic Framework : ionic-angular 3.9.3
@ionic/app-scripts : 3.2.2
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 6.3.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 18 other plugins)
System:
NodeJS : v9.8.0 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b
with angular/core@5.2.11
i made app-routing.module.ts:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', loadChildren: '../pages/home/home.module#HomePageModule'}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
app.module.ts looks:
import { AppRoutingModule } from '../app/app-routing.module';
...
imports: [
RouterModule,
CommonModule,
AppRoutingModule,
...
home.module.ts is:
import { NgModule } from '@angular/core';
import { HomePage } from './home';
import { TranslateModule } from '@ngx-translate/core';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from 'ionic-angular';
import { CommonModule } from '@angular/common';
const routes: Routes = [
{ path: '', component: HomePage }
];
@NgModule({
declarations: [HomePage],
imports: [
IonicModule,
CommonModule,
RouterModule.forChild(routes),
TranslateModule.forChild()
],
exports: [RouterModule]
})
export class HomePageModule { }
app.html:
<ion-app>
<ion-router-outlet></ion-router-outlet>
</ion-app>
app.component.ts:
...
@Component( {
templateUrl: 'app.html'
} )
...
this.router.navigateByUrl('/home');
With this code i am getting :
Templete parse errors: "ion-router-outlet" is not a known element: 1. If "ion-router-outlet" is an Angular component, then verify that it is part of this module. ...
if i use “router-outlet” (without )i have this error :
Uncaught (in promise). Error: Cannot find module '../pages/home/home.module'. Error: Cannot find module '../pages/home/home.module' at ...
Unfortunately i cant find any proper guide how to migrate the lazy loading