Close an auxiliary route from anywhere in an Angular 2 application

How to get route information without aux route? The scenario is to close the aux route, to do this, I am going to delete the aux route information from the current route and go to the new route,

So, I am looking to cut aux1-routefrom 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 indicate if there is an alternative way to close the aux route from anywhere in the application.

Thanks in advance!

+4
source share
1 answer

I managed to solve this using the code below,

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

Source: https://habr.com/ru/post/1651089/


All Articles