Cannot match any routes. URL Segment: 'subscription/plan'

Viewed 34

I have an app routing module:

const routes: Routes = [
  {path: '', redirectTo: 'main', pathMatch: 'full'},
  {path: 'main', component: MainPageComponent},
  {path: 'subscription', loadChildren: () => import('./pages/subscription/subscription.module').then(m => m.SubscriptionModule)}
];

where subscription module is lazy loaded.

Here is my subscription routing module:

 const routes: Routes = [
      {
        path: '',
        component: SubscriptionComponent,
        pathMatch: 'full',
        children: [
          {path: 'plan', component: PlanComponent},
          {path: 'delivery-days', component: DeliveryDaysComponent},
          {path: 'dishes', component: DishesComponent},
          {path: 'payment', component: PaymentComponent}
        ]
      }
    ];
@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class SubscriptionRoutingModule { }

When I try to go to '/subscription/plan' it throws error. I have <router-outlet></router-outlet> in my subscription.html.

I also have a question: how to redirect to '/subscription/plan' whenever I go to '/subscription'

0 Answers
Related