Sani Yusuf PRO
Founder Of Haibrid. Co-Organiser Of Ionic UK. I Am Good At Making You Want To Use Ionic.
Founder Of Haibrid
Author & Trainer
Big Fan Of Avatar Movie
Home.html
Profile.html
Index.html
about.html
contact.html
profile.html
index.html
about.html
The routing is happening on the front-end
We must load all Partials at the first launch
Initial launch time grows as we add more code to our SPA
Terrible for user experience
Built-in component routing
Uses Javascript import() Syntax
Allows for a custom strategy for lazy loading
const routes: Routes = [
{
path: 'items',
loadChildren: () => import('./items/items.module').then(m => m.ItemsModule)
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
})
import { NgModule } from "@angular/core";
import {
Routes,
RouterModule,
PreloadingStrategy,
PreloadAllModules
} from "@angular/router";
@NgModule({
imports: [
RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules
})
],
})
What of the case when we want to load a component on its own?
Lazy loading only allows us to load routes
By Sani Yusuf
Lazy Loaded Components In Angular
Founder Of Haibrid. Co-Organiser Of Ionic UK. I Am Good At Making You Want To Use Ionic.