现在,要完成最后一步并在我们的app-routing.module.ts文件中实现这些路由,它们将如下所示:
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', loadChildren: './pages/home/home.module#HomeModule' },
{ path: 'products', loadChildren: './pages/products/products.module#ProductsModule'},
{ path: 'products/:id', loadChildren: './pages/product-detail/product-detail.module#ProductDetailModule' },
{ path: 'products/categories', loadChildren: './pages/product-categories/product-categories.
{ path: 'support', loadChildren: './pages/support/support.module#SupportModule' }
];
html页面中的setRoot
<ion-button href="/support" routerDirection="root">
或在课堂上
this.navCtrl.navigateRoot('/support');
推
<ion-button href="/products/12" routerDirection="forward">
或者
this.navCtrl.navigateForward('/products/12');
流行音乐
<ion-button href="/products" routerDirection="backward">
或者
<ion-back-button defaultHref="/products"></ion-back-button>
您还可以以编程方式向后导航:
this.navCtrl.navigateBack('/products');
p/s:https ://www.joshmorony.com/converting-ionic-3-push-pop-navigation-to-angular-routing-in-ionic-4/