The Problem
I managed to isolate the problem to the line
outlet2: 'aux-3'
If we check the link created for <a [routerLink]="['/level-0', { outlets: { primary: ['level-1', { outlets: { primary: ['level-2', { outlets: { primary: ['level-3'], outlet2: 'aux-3' } }] } }], outlet1: 'aux-1' } }]">L1-A1/L2/L3-A3</a>
we see that it produces
/level-0/(level-1/(level-2/(level-3//outlet2:a/u/x/-/3))//outlet1:aux-1)
It seems that aux-3
is converted to a/u/x/-/3
. which is definitely not expected. It looks like the letters have been split and joint with /
.
Solution/ Workaround
As stated earlier it seems an array was expected in the router outlet, so a simple solution is to pass an array instead
outlet2: ['aux-3']
<a [routerLink]="['/level-0', { outlets: { primary: ['level-1', { outlets: { primary: ['level-2', { outlets: { primary: ['level-3'], outlet2: ['aux-3'] } }] } }], outlet1: ['aux-1'] } }]">L1-A1/L2/L3-A3</a>
Now the correct link is produced and the routes work correctly
Is there somethink wrong with my routing?
Your routes are working correctly. But as you may have noticed there is some inconsistency in the way the links are produced. I tried a simple router-link in This Stackblitz and it produces the same link.
<a [routerLink]="['/', { outlets: { outlet1: ['ab'] } }]">Link 1|</a> <br />
<a [routerLink]="['/', { outlets: { outlet1: 'ab' } }]">Link 2</a>
Below is the result of implementing the above
Working stackblitz demo
Auxilliary routes on Lazy loaded modules
A simple explanation to the problem you are facing is highlighted in this question Named router outlet and lazy loaded modules with a link provided in this answer https://stackoverflow.com/a/49367379/13680115 i.e auxilliary routes are not supported out of the box
Lazy load auxilary #10981
In the above post, In this comment the user highlights below
It seems that lazy load and auxiliary routes are not widely used together.
We can see a lot of demos, separated but that's it. It's like no one uses it in a medium/large app 😮
In the same post there seems to be a workaround here
We create a nested route with a componentless parent route. I have implemented that in the demo below and it works for the 1st level lazy loaded module. For the next level the routes are properly matched with no errors but unfortunately the component is not loaded, I believe a solution is to simply move the one level to the parent component. This way, one level of the auxilliary routes is loaded in the parent module while the other in the lazy loaded module
Demo Stackblitz