Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change only the aux: outlet in Angular2 Router@3 (Vladivostok)

I have a users table. When I click a user, I want a modal with some of their data up there. How do I trigger the route change only for the aux router? And how would I do that in the first place, anyway?

What I want is essentially to go from:

/users

to

/users(aux:/user:12345)

(12345 would be the userId here.)

Preferably I want to navigate without page reload, of course :)

How would I link to this via [routerLink] attribute, and how via manually calling router.navigate?

like image 290
Zlatko Avatar asked Nov 09 '22 13:11

Zlatko


1 Answers

Your router config:

...
{ path: 'user/:id', component: UsersComponent, outlet: 'aux' }
...

Using routerLink:

<a [routerLink]="[{ outlets: { 'aux': ['user', '12345'] } }]">
  Component Aux
</a>

From the component:

this.router.navigate([{outlets: {aux: 'user/12345'}}]);
like image 196
Sonu Kapoor Avatar answered Nov 15 '22 07:11

Sonu Kapoor