Skip to content

Commit 72fd222

Browse files
JeevanMaheshadevversion
authored andcommitted
docs: add documentation for lazy loading a standalone component (angular#57620)
Added a new section in the documentation explaining how to lazy load a standalone component using `loadComponent`. This includes a code example demonstrating the setup in Angular routes. PR Close angular#57620
1 parent 9a67e12 commit 72fd222

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

adev/src/content/guide/routing/common-router-tasks.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,20 @@ gotoItems(hero: Hero) {
474474
You can configure your routes to lazy load modules, which means that Angular only loads modules as needed, rather than loading all modules when the application launches.
475475
Additionally, preload parts of your application in the background to improve the user experience.
476476

477+
Any route can lazily load its routed, standalone component by using `loadComponent:`
478+
479+
<docs-code header="Lazy loading a standalone component" language="typescript">
480+
481+
const routes: Routes = [
482+
{
483+
path: 'lazy',
484+
loadComponent: () => import('./lazy.component').then(c => c.LazyComponent)
485+
}
486+
];
487+
</docs-code>
488+
This works as long as the loaded component is standalone.
489+
490+
477491
For more information on lazy loading and preloading see the dedicated guide [Lazy loading](guide/ngmodules/lazy-loading).
478492

479493
## Preventing unauthorized access

0 commit comments

Comments
 (0)