0

Aux route inside child route, don't know how to set to let it work. i have root component and route config file like:

root.routes.ts     
 export const rootRoute:RouterConfig=[
       ...ChildrenRoute,
       {path:'',component:ChildrenRootComponent},
       {path:'children-root',component:ChildrenRootComponent},
       {path:'other',component:OtherComponent'}
  ];

 template:
          '<a routerLink='children-root'>Children root</a>
           <a routerLink='other'>Other</a>
           <router-outlet></router-outlet>'

and ChildrenRootComponent have FirstComponent and SecondComponent with routes config file like:

 children.routes.ts    
     export const ChildrenRoute:RouterConfig=[
        {path:"",redirectTo:'/children-root',pathMatch:'full'},
        {path:'children-root',component:ChildrenRootComponent,
               children:[
                    {path:'',component:FirstComponent},
                    {path:'first',component:FirstComponent},
                    {path:'second',component:SecondComponent,outlet:'aux'}
               ]
        }
    ];
template:
         ' <a routerLink='first'>First</a>
              <router-outlet></router-outlet>
           <a routerLink='aux:second'>Second</a>
              <router-outlet name="aux"></router-outlet>'

Now route from Children root -> Second is ok, but route Children root -> first doesn't work show error:

 Error: Cannot match any routes: 'children-root/second'

change template:

   ' <a routerLink='first'>First</a>
          <router-outlet></router-outlet>
     <a routerLink='(aux:second)'>Second</a>
          <router-outlet name="aux"></router-outlet>'

doesn't work too. error:

Error: Cannot match any routes: 'children-root/second)'

pay attention here ')' in error message,and no '(' . directly set url as following in browser

 localhost:4200/children-root/(aux:second) 

reload and work well. so i guess i set routerLink wrong, search a lot, no find anything about this.

Arpit Agarwal
  • 3,993
  • 24
  • 30
PengGang
  • 15
  • 5

3 Answers3

1

RC.4 doesn't support routerLink with aux routes yet. Try something like this:

<a href="/children-root/(aux:second)">Second</a>

Yakov Fain
  • 11,972
  • 5
  • 33
  • 38
1

Rc4. Doesn't support routerLink properly yet. You can achieve the desired result using navigateByUrl or manual 'a' tag. I assume your first componet is visible when you try to navigate to second. Then try

this.router.navigateByUrl('/children-root/(first//aux:second)');

Or

<a href="/children-root/(first//aux:second)">Second</a>

The explanation of route URL formation can be read at this

Community
  • 1
  • 1
Arpit Agarwal
  • 3,993
  • 24
  • 30
0

It has just been fixed. We shall see it working in the upcoming RC.5

related GitHub issue

Norbert Korny
  • 938
  • 1
  • 9
  • 8