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
Post a Comment