1
votes

My code is as follows :

app component html

<app-header ></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>

routing.ts:

  const routes: Routes = [
     { path: 'register', component: RegisterComponent, 
           children: [
                {
                 path: 'page/:slug',component: PagesComponent, 
                 outlet: 'bookLists'
           },
     ]},
  ];

  @NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule]
  })
  export class AppRoutingModule { }

component.html:

  <label for="CustomerAcceptTerms" class=" control-label emaillabel">
  <input type="checkbox" name="terms" value="1"id="CustomerAcceptTerms"> I 
       accept and understand the
  <a [routerLink]="['/register',{ outlets: { bookLists: ['page/terms-and-conditions'] } }]" routerLinkActive="active">Book Details</a>
  </label>

app.component.html:

    <app-details></app-details>
    <router-outlet></router-outlet>
    <router-outlet name="bookLists"></router-outlet>

and error is:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'register'

1
What does the link shows when you inspect it in the browser? My guess is it shows /register/register, so the router looks for child inside register inside RegisterComponent.Denis

1 Answers

1
votes

I had a similar bug few month back and reported it on github (https://github.com/angular/angular/issues/14896). Unfortunately it never got resolved till now.

I had to set the routing for the auxiliary route as separate route, not as a child route.