<ion-router-outlet>在离子4

时间:2018-12-20 06:55:14

标签: angular-routing ionic4

嗨,我正在尝试使用下面的代码在ionic 4的父页面中添加两个子页面的两个子页面,但是当我选择要显示各个页面的选项卡但其直接显示child1时,我对不显示两个选项卡感到困惑页面

我想知道我何时可以正常使用它,请向我建议我在哪里做错了?

admin.html

<ion-content padding>
  <ion-row>
    <ion-col col-4><button ion-button color="secondary" (click)="child1()">Child1</button></ion-col>
    <ion-col col-4><button ion-button color="secondary" (click)="child2()">Child2</button></ion-col>
  </ion-row>
  <ion-router-outlet></ion-router-outlet>

</ion-content> 

admin-router.module.ts

const routes: Routes = [
    {
        path: 'Admin',
        component: AdminPage,
        children: [
            { path: '',redirectTo: '/Admin/Child1',pathMatch: 'full'},
            { path: 'Child1', component: Child1Page },
            { path: 'Child2', component: Child2Page },
        ]
    }
];

adminModule.ts

@NgModule({
    imports: [
        CommonModule,
        IonicModule,
        AdminRoutingModule
    ],
    declarations: [
        AdminPage,
        Child1Page,
        Child2Page
    ]
})
export class AdminModule {

}

1 个答案:

答案 0 :(得分:0)

尝试使用成角度的router-outlet而不是ion-router-outlet