NativeScript Angular-无法在位于不同页面路由器出口的同级视图之间导航

时间:2019-01-28 12:12:20

标签: angular nativescript angular-routing nativescript-angular

我有这个TabView组件:

<TabView androidTabsPosition="bottom">
  <page-router-outlet *tabItem="{title: 'Item 1'}" name="map"></page-router-outlet>
  <page-router-outlet *tabItem="{title: 'Item 2'}" name="subscribe"></page-router-outlet>
</TabView>

路由器配置:

  {
    path: '',
    redirectTo: '/(map:map//subscribe:subscribe)',
    pathMatch: 'full'
  },
  {
    path: 'map',
    loadChildren: '~/app/routes/+map/map.module#MapModule',
    outlet: 'map'
  },
  {
    path: 'subscribe',
    loadChildren: '~/app/routes/+subscribe/subscribe.module#SubscribeModule',
    outlet: 'subscribe'
  }

在功能模块SubscribeModule中,我有一个应导航到map路线的功能:

// The NativeScript router service
constructor(private router: RouterExtensions) {}

navigate(args) {

  const item = this.items[args.index];

  this.router.navigate(['map'], {
    transition: {
      name: 'slideLeft',
      duration: 300
   }
  });
}

但是我一直得到的只有Error: Cannot match any routes. URL Segment: 'map'

我也尝试了以下方法:

  • 使用this.router.navigate([{outlets: {map: 'map'}}]导航到指定的插座
  • 使用this.router.navigate(['../', 'map'])导航
  • 使用navigateByUrl导航

但是它们都产生相同的结果。

我可能做错了什么?

1 个答案:

答案 0 :(得分:0)

请在下面尝试

this.router.navigate([“ / map”],{     过渡: {       名称:“ slideLeft”,       持续时间:300    }   });

尝试添加私有activeRoute:组件中的ActivatedRoute

this.router.navigate([{奥特莱斯:{搜索:[“ map”]}}}],{relativeTo:this.activeRoute});

相关问题