Angular 2
정적 URL에 대한 / route / subroute와 같은 경로의 예
수색…
하위 라우트 트리를 사용한 기본 라우트 예제
app.module.ts
import {routes} from "./app.routes";
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, mainModule.forRoot(), RouterModule.forRoot(routes)],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.routes.ts
import { Routes } from '@angular/router';
import {SubTreeRoutes} from "./subTree/subTreeRoutes.routes";
export const routes: Routes = [
...SubTreeRoutes,
{ path: '', redirectTo: 'home', pathMatch: 'full'}
];
subTreeRoutes.ts
import {Route} from '@angular/router';
import {exampleComponent} from "./example.component";
export const SubTreeRoutes: Route[] = [
{
path: 'subTree',
children: [
{path: '',component: exampleComponent}
]
}
];
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow