Ionic5 Modal Routes

Viewed 382

I have a swipeable modal that has a button on it. When the user taps, I need to dismiss the modal and navigate to another component. I have done the routes and everything but I get an error:

Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'sub-detail'

If I navigate from the parent component, without going through the modal it works.

I think the modal is creating it own routes. Is there a way around that? I feel like I need to "step away" from the modal to navigate.

Thanks

modal.component.ts

async goTo(where: string) {
    await this.modalCtrl.dismiss();
    this.router.navigate('sub-detail');
}

module

imports: [
    CommonModule,
    RouterModule.forChild([
          { path: '', pathMatch: 'full', component: SubscriptionComponent },
          { path: 'sub-detail', component: SubscriptionDetailsComponent },
          { path: 'options', component: SubscriptionModalComponent },
    ]),
    IonicModule,
    UniversalModules
],
1 Answers

You can not navigate anywhere from modal so let modal finish and back to page then do navigate.

Related