【发布时间】:2019-12-02 22:25:02
【问题描述】:
在我的 NativeScript 应用程序中,有一个 BottomNavigation 选项卡:
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>
导航到该选项卡时,列表会按预期填充,但如果您导航到另一个选项卡的子组件,然后直接返回到底部导航:
子组件:
this.router.navigate([
'../tabs'
]);
ListView 中之前加载的所有项目都消失了...之前未加载的项目将开始填充列表
【问题讨论】:
-
您是否尝试在 relativeTo 上传递 ActivatedRoute?你能分享一个可以重现问题的最小 Playground 示例吗?
-
@Manoj 这里是一个示例游乐场:play.nativescript.org/?template=play-ng&id=K3w4he&v=5 每当您在服务将项目加载到列表后从列表视图导航时,这些项目将“丢失”并且在您导航回时不会出现列表视图
标签: nativescript angular2-nativescript nativescript-angular