其他页面中的离子路由器出口

问题描述 投票:1回答:1

我有一个离子角项目,并且在app.component.html中有离子路由器出口,可重定向到教师页面

app-routing.module.ts中的路由

const routes: Routes = [
  {
     path: '',
     redirectTo: 'teacher',
     pathMatch: 'full'
  },
  {
     path: 'login',
     component: LoginComponent
  },
  {
     path: 'teacher',
     loadChildren: () => import('./pages/teacher/teacher.module').then(m => m.TeacherPageModule)
  },
  {
     path: 'admin',
     loadChildren: () => import('./pages/admin/admin.module').then(m => m.AdminPageModule)
  }
];

并且在教师页面中,我重定向到课程页面

teacher-routing.module.ts

const routes: Routes = [
  {
     path: '',
     redirectTo: 'classes',
  },
  {
     path: 'classes',
     component: ClassesComponent
  }

];

并且我想在教师页面上显示课程页面

teacher.page.html

<ion-header>
    <ion-toolbar>
        <ion-title>teacher</ion-title>
    </ion-toolbar>
</ion-header>

<ion-content>
  <ion-router-outlet></ion-router-outlet> //<< classes page in here
</ion-content>

但是它仅显示课程页面的内容,而不执行教师页面。

angular ionic-framework angular-router router-outlet
1个回答
0
投票

似乎我还没有在Route中将'loadChildren'路由声明为'classes'。类似于:

  {
     path: 'classes',
     loadChildren: () => import('./pages/classes/classes.module').then(m => m.ClassesPageModule)
  }
© www.soinside.com 2019 - 2024. All rights reserved.