路由回底部导航组件后,NativeScript ListView项将消失
在我的NativeScript应用程序中,有一个底部导航选项卡:路由回底部导航组件后,NativeScript ListView项将消失,nativescript,angular2-nativescript,nativescript-angular,Nativescript,Angular2 Nativescript,Nativescript Angular,在我的NativeScript应用程序中,有一个底部导航选项卡: const routes: Routes = [ { path: 'tabs', component: TabsComponent, children: [ { path: 'feed', loadChildren: '~/app/pages/feed/feed.module#FeedMo
const routes: Routes = [
{
path: 'tabs',
component: TabsComponent,
children: [
{
path: 'feed',
loadChildren: '~/app/pages/feed/feed.module#FeedModule',
component: NSEmptyOutletComponent,
outlet: 'feedTab'
},
{
path: 'notification',
loadChildren: '~/app/pages/notification/notification.module#NotificationModule',
component: NSEmptyOutletComponent,
outlet: 'notificationTab'
},
{
path: 'create',
loadChildren: '~/app/pages/create/create.module#CreateModule',
component: NSEmptyOutletComponent,
outlet: 'createTab'
},
{
path: 'profile',
loadChildren: '~/app/pages/profile/profile.module#ProfileModule',
component: NSEmptyOutletComponent,
outlet: 'profileTab'
}
]
}
];
在其中一个子选项卡中,有一个项目的RadListView:
<ActionBar id="profile-action-bar" title="Notifications"></ActionBar>
<GridLayout>
<RadListView separatorColor="transparent" class="notification-list" [items]="notificationList"
(loadMoreDataRequested)="onLoadMoreItemsRequested($event)" loadOnDemandMode="Auto"
(itemTap)="onNotificationTap($event)">
<!-- (itemTap)="onGoalTap($event)" -->
<ng-template let-item="item" let-i="index">
<ns-notification-item [item]=item [position]=i></ns-notification-item>
</ng-template>
</RadListView>
</GridLayout>
ListView中以前加载的所有项目都已消失…以前未加载的项目将开始填充列表,但是路由器出口和页面路由器出口有一个主要区别。在web上,当您导航当前路由上的所有组件时,将销毁并呈现导航路由的新组件 使用移动应用程序,您可以保留导航堆栈,从左到右返回上一页。为此,您使用页面路由器出口,并处理您需要的页面路由器出口 当您想返回历史记录中的上一页时,应该调用
RouterExtensions
上的back()
方法
您是否尝试通过relativeTo上的ActivatedRoute?你能分享一个可以重现问题的最小游乐场示例吗?@Manoj这里有一个示例游乐场:每当你在服务将项目加载到列表后从listview导航时,这些项目将“丢失”,并且在你导航回listviewOk时不会出现。这很有意义,但是,如果你所航行的路线是两条“更深”的路线呢?或者可能有三条路深。有没有比使用多个
routerExtensions.back()调用更好的方法?你能直接走到第一个组件吗?我把这个概念添加到[操场]()哎呀!这是正确的操场:
this.router.navigate([
'../tabs'
]);