Route의 지정된 loadChildren 특성을 사용하여 NgModule을 사용하여 느린 로딩을 수행 할 수있었습니다.Angular2 (RC5)에서 단일 구성 요소를 게으른로드하는 방법
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 {}
그러나 "구성 요소"속성에 대한 문자열을 사용하여 (AN NgModule 반대) 게으른 부하에 하나의 구성 요소를 경로를 구성하는 방법은 무엇입니까?
난 항상 같은 오류에 geting 결국 :
import { Routes, RouterModule } from '@angular/router';
const routes: Routes= [{path: 'welcome', loadChildren: 'app/screens/welcome.module'}];
export const routing = RouterModule.forRoot(routes);
여기 :
이 그런 다음 필요에 따라로드
구성 요소를 자체 모듈로 이동할 수 있습니다. –
음 ... 알아. 하나의 구성 요소 만 랩핑하면 불필요한 "상용구"처럼 보입니다. 이것이 유일한 방법이라고 말하고 있습니까? 왜냐하면 Route의 "구성 요소"속성은 문자열이 될 수 있으므로 구성 요소를 지연로드하려는 의도가있는 것처럼 보입니다. – noxborough
그것은 RC.5 이전의 길이었습니다. 따라서 아직도 일하기로되어 있는지 나는 모른다. –