Issue
Is it possible to lazy load standalone component for multiple path's? Is this a proper way to do it?
{ path: 'path1', loadComponent: () => import('./someComponent.component').then(c => c.someComponent)},
{ path: 'path2', loadComponent: () => import('./someComponent.component').then(c => c.someComponent)},
In main.ts file I also set preoload strategy to preload all modules:
provideRouter(APP_ROUTES, withPreloading(PreloadAllModules))
I checked newtwork in DevTools and it looks like component is loaded only once. However I am not sure if this is the correct way of implementing it.
Solution
The way you are lazy leading is absolutely fine. because regardless of how many times you are lazy loading a component or a module, it will load only the first time and the next time Angular loads the same route or another route with same component or module, Angular will use the already loaded component or module.
Answered By - Vishnu Vinod
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.