I managed to get lazy loading to work with NgModules using the prescribed loadChildren Route attribute.
import {RouterModule} from ‘@angular/router’
import {NgModule} from ‘@angular/core’
@NgModule({
declarations: [ MyComponent, MyHomeRoute ],
bootstrap: [ MyComponent ],
imports: [
RouterModule.forRoot([
{ path: ‘home’, component: MyHomeRoute },
{ path: ‘lazy’, loadChildren: ‘./my-lazy-module’ }
])
})
class MyAppModule {}
But is there a way to configure Route to lazily load a single component (unlike NgModule) using the string for the "component" attribute?
I always get errors like:
"Unable to resolve component using" lazyComponent "
source
share