how to go to another page with a button click with ionic?

后端 未结 12 1807
粉色の甜心
粉色の甜心 2020-12-31 10:26

I have been trying to work with the code, I added the button but I don\'t know how to link it to another page when clicking on it.

12条回答
  •  -上瘾入骨i
    2020-12-31 10:40

    Basically you would navigate to a different page in the same way as if you were in Angular.

    Important thing to remember is that Ionic routes are essentially Angular routes. To learn more about how they work, visit: https://angular.io/guide/router

    To answer your question.

    Let's imagine you want to redirect a user to your About page.

    Within your app-routing.module.ts you have a path that goes:

    {
        path: 'about',
        loadChildren: () => import('./pages/about/about.module').then( m => m.AboutPageModule)
      }

    Then in the tags of a button, you want add the classical Angular router call that goes like this:

    Go!

    Basically, routerLink="/name-of-the-path" can be used on your buttons or tags to redirect the user to the desired location.

    Hope this helps!

提交回复
热议问题