Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close the Auxiliary route from anywhere in the Angular 2 application

How to get the Route info without the aux route? The scenario is to close out the aux route, to do that I am thinking of stripping down the aux route info from the current route and navigate to new route,

So what I am looking for is to strip down aux1-route from the current route.

/route1(aux1:aux1-route;id=123)  -> /route1
/route1(aux1:aux1-route;id=123//aux2:aux2-route) -> /route1(aux2:aux2-route)

app.html

<router-outlet></router-outlet>
<router-outlet name='aux1'></router-outlet>
<router-outlet name='aux2'></router-outlet>

route configuration

{ path: "route1", component: route1Component }
{ path: "aux1-route", component: aux1RouteComponent, outlet: "aux1" }
{ path: "aux2-route", component: aux2RouteComponent, outlet: "aux2" }

Angular 2 version : 2.0.0-rc.5

Angular Router version : 3.0.0-rc.1

Please also suggest if there is any alternate way to close the aux route from anywhere in the application.

Thanks in advance!!

like image 881
Madhu Ranjan Avatar asked Aug 12 '16 15:08

Madhu Ranjan


1 Answers

I was able to resolve this using below code,

  this.router.navigate([{ outlets: { aux1: null } }]);

Check this Angular documentation

like image 186
Madhu Ranjan Avatar answered Oct 27 '22 21:10

Madhu Ranjan