问题
I'm trying to use Angular 2 rc-4 with new Router.
export const appRoutes:
RouterConfig =[
{
path: "",
component: HomeComponent,
terminal: true,
data: {
title: "Home"
}
},
{
path: "Users",
component: UserListComponent,
data: {
title: "Users"
}
},
{
path: "Users/:id",
component: UserEditComponent,
data: {
title: "Edit User"
}
}
];
Then I subscribe to change route event. When event fires I want to find item from
appRoutes
The problem is with url with params:
Users/:id
I don't know how to compare it with current page url or how to ask RouterConfig.
Can you please help me?
回答1:
AS I found, best solution is to get current route using subscription to route change event. Based on this route you can get all data and check params. If you have better solution please add your answer too.
来源:https://stackoverflow.com/questions/38874655/angular-2-routes-current-url-with-params