아래에 나와있는 것처럼 자식 경로를 하드 코드했습니다. 하지만 JSON 개체를 사용하여이를 구축하고 싶습니다. 즉, 아래에 동적으로 추가해야하며 해당 구성 요소를 자동으로 가져와야합니다. JSON 객체도 파일에 저장할 수 있습니다. 요구 사항을 달성 할 수있는 방법이 있습니까?JSON 객체를 사용하여 동적으로 자식 경로를 작성하십시오.
[
{ path: 'step1', component: aComponent },
{ path: 'step2', component: bComponent },
{ path: 'step3', component: cComponent },
{ path: 'step4', component: dComponent },
{ path: 'step5', component: eComponent },
{ path: 'step6', component: fComponent }
]
최종 결과는 다음과 같아야합니다.
export const abcRoutes: Routes = [
{
path: '',
component: abcLandingComponent,
children: [
{ path: 'step1', component: aComponent },
{ path: 'step2', component: bComponent },
{ path: 'step3', component: cComponent },
{ path: 'step4', component: dComponent },
{ path: 'step5', component: eComponent },
{ path: 'step6', component: fComponent }
]
}
질문을 올바르게 이해했다면, 경로를 정의한 main.ts 파일에이 종류의 모듈을 갖고 싶습니까? 그렇다면 어떻게 경로를 정의 할 것인가? 그것은 뭔가 다른 경로 일 수도 있습니다 : '무언가'? 그 시나리오를 어떻게 다루겠습니까? 또는 경로 속성에 대해 몇 가지 규칙을 설정 했습니까? –
최종 결과 형식으로 내보내기하여 모듈로 가져올 수 있습니까? –