angular - How do I navigate to a sibling route? -


let's presume got router config

export const employeeroutes = [    { path: 'sales', component: salescomponent },    { path: 'contacts', component: contactscomponent } ]; 

and have navigated salescomponent via url

/department/7/employees/45/sales 

now i'd go contacts, don't have parameters absolute route (e.g. department id, 7 in above example) i'd prefer there using relative link, e.g.

[routerlink]="['../contacts']" 

or

this.router.navigate('../contacts') 

which unfortunately doesn't work. there may obvious solution i'm not seeing it. can out here please?

if using new router (3.0.0-beta2), can use activatedroute navigate relative path follow:

constructor(private router: router, private r:activatedroute) {}   /// gotocontact() {   this.router.navigate(["../contacts"], { relativeto: this.r }); } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -