1
저는 게으른 로딩을 사용하여 Angular 2 프로젝트에서 작업했습니다. 잘 작동하지만 서버에서 모듈 이름을 가져온 다음 경로를 만들면되지만 작동하지 않습니다. 여기angular 2 게으른 로딩 - 서버의 경로
import { Routes, RouterModule } from '@angular/router';
function getRoutes(): Routes{
let x: any = [
{path: '', redirectTo: 'welcome', pathMatch: 'full'},
{path: 'backend', loadChildren: 'app/backend/backend.module'}
]
return x;
}
export const routes: Routes = routess();
export const routing = RouterModule.forRoot(routes);
그리고이다, 내가 무엇이 필요합니까 :
import { Routes, RouterModule } from '@angular/router';
function getRoutes(): Routes{
let x: any;
$.get("api/getRoutes", function(data) {
x = data; //object array from server
});
return x;
}
export const routes: Routes = routess();
export const routing = RouterModule.forRoot(routes);
문제는 함수 getRoutes
서버의 결과 반환을 기다리고되지 않는다는 것을 여기
서버 데이터를 기다린 다음 경로에 데이터를 추가 할 수있는 방법이 있습니까?
감사합니다. –