I have two routes with a different path
and name
but with the same component
. Is there a way to check what the path is when I navigate for ex. to /add-user
OR the name
for ex. AddUser
Routeconfig
app.component.ts
@RouteConfig([
{
path: '/add-user',
name: 'AddUser',
component: UserComponent
},
{
path: '/user/:id/detail',
name: 'UserDetail',
component: UserComponent
}
])
Update
Usercomponent
user.component.ts
ngOnInit() {
//this is pseudocode
if (this._router.name == 'AddUser') {
console.log('you want to add a user')
}
else{
console.log('you want to see the details of a user');
}