Angular 2 - 路由 - 在浏览器地址栏中显示不同的路由名称
Angular 2 - Routing- Showing different route name in the browser address bar
是否可以在 angular 2 和 4 中的特定路线的地址栏中显示州名称。例如,我有以下路线配置,
{
path:"animals",
component : AnimalComponent,
children:[{
path:"cat",
component:CatComponent
},{
path:"dog",
component:DogComponent
}]
}
当地址为 "animals/cat" 时,它在 AnimalComponent router-outlet 中加载 CatComponent,当地址为 "animals/dog" 时,它在 AnimalComponent router-outlet 中加载 DogComponent。是否可以在 "animals/cat" 的地址栏中仅显示 "cat" 和 "animals/dog" 路由的地址栏中的 "dog"。
当然,只需从 parent 路由中删除路径:
{
path:"",
component : AnimalComponent,
children:[{
path:"cat",
component:CatComponent
},{
path:"dog",
component:DogComponent
}]
}
angular 将自动 link children 到最近的祖先(如果没有则为根)
是否可以在 angular 2 和 4 中的特定路线的地址栏中显示州名称。例如,我有以下路线配置,
{
path:"animals",
component : AnimalComponent,
children:[{
path:"cat",
component:CatComponent
},{
path:"dog",
component:DogComponent
}]
}
当地址为 "animals/cat" 时,它在 AnimalComponent router-outlet 中加载 CatComponent,当地址为 "animals/dog" 时,它在 AnimalComponent router-outlet 中加载 DogComponent。是否可以在 "animals/cat" 的地址栏中仅显示 "cat" 和 "animals/dog" 路由的地址栏中的 "dog"。
当然,只需从 parent 路由中删除路径:
{
path:"",
component : AnimalComponent,
children:[{
path:"cat",
component:CatComponent
},{
path:"dog",
component:DogComponent
}]
}
angular 将自动 link children 到最近的祖先(如果没有则为根)