【发布时间】:2017-12-29 15:19:49
【问题描述】:
例如: 'www.xyz.com/#/indutry/1/subIndustry/2/subSubIndustry/3'
我需要遵循这个结构,我如何才能 ForRoot 我的父路由文件
【问题讨论】:
-
您使用哪个 Angular 版本?
-
现在角度为 4
标签: angular angular-routing angular-router
例如: 'www.xyz.com/#/indutry/1/subIndustry/2/subSubIndustry/3'
我需要遵循这个结构,我如何才能 ForRoot 我的父路由文件
【问题讨论】:
标签: angular angular-routing angular-router
您需要两级嵌套子路由。
确保每条路线都有一个唯一的名称。
您的路线文件。
这个基本示例,取决于您的应用要显示哪种数据。
const routes: Routes = [
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{
path: 'indutry/:indutryId',
component: IndutryComponent,
children: [
{path: '', redirectTo: 'subIndustryone', pathMatch: 'full'},
{
path: 'subIndustryone/:subindustryOneId',
component: SubIndustryOneComponent,
children : [
{ path : '', redirectTo: 'subIndustrytwo', pathMatch : 'full' },
{ path : 'subIndustrytwo/:subindustryTwoId', component : SubIndustryTwoComponent },
]
},
]
},
{path: '**', component: HomeComponent}
];
【讨论】: