In angular is it possible to load component in lazy without specify ngModule
?
Today I use:
{ path: '..', loadChildren: () => import('./my.module').then(m => m.myModule) }
Can I do something like this code:
{ path: '..', component: () => import('./my.component') }
Is it possible? if so how?
I found this tutorial which I think can help you. In order, you need to declare the component as part of this module, then to load component only when it's used, helped by ComponentFactoryResolver and Injector
Yes, you can load component lazily without including it in NgModule. you can import component in code where you need and then by using ComponentFactory Resolver and ViewComponentRef, check the article
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.