Ionic/Angular - Multiple routes not working

邮差的信 提交于 2019-12-02 11:40:48

I'm not an Ionic developer, but in a basic Angular application it would make more sense to define the friends, nearme and global routes as child routes, not named secondary routes.

This code:

<ion-content>
  <ion-router-outlet name="friends"></ion-router-outlet>
  <ion-router-outlet name="nearme"></ion-router-outlet>
  <ion-router-outlet name="global"></ion-router-outlet>
</ion-content>

Is telling Angular to build a "dashboard" type display with all three components possibly showing at the same time.

If you only want to show friends OR nearme OR global, use child routes instead.

This code defines one router outlet that you can route any of the content to.

<ion-content>
  <ion-router-outlet></ion-router-outlet>
</ion-content>

And change the route definitions to remove the outlet name:

    children: [
      {
        path: 'friends',
        component: FriendsComponent
      },
      {
        path: 'nearme',
        component: NearMeComponent
      },
      {
        path: 'global',
        component: GlobalComponent
      }
    ]
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!