I am using Angular 6. I have 2 router outlets a primary and a named. For a navigation to a route I need to navigate from a component not the template. If I ignore the outlets can call with a typical router.navigate the primary is loaded without issue:
this.router.navigate(['sp/auth', { "myid": obj.code }]);
But if I try this defining the outlet I just get redirected to a non matching route.
this.router.navigate([{
outlets: {
primary: ['sp/auth', obj.code ]
}
}]);
Ultimately I will add the second named outlet to this call but I cannot get it to function with just the primary. I have tried prefixing with / (aboslute) but this just gets url encoded when looking at the router trace.
This is the route
{path: 'sp/auth/:spID', component:SpAuthComponent},
The outlets work for other pages that use the routerLink. It is just when using the router.navigate in the component that the route is not found. I must be missing something.
this.router.navigate(['/', { outlets: { primary: ['sp/auth', obj.code ] } }]);(note the '/' as first argument of the array) - maxime1992