当我导航到相同的组件(使用nativescript angular)时,我可以拦截params更改但是当我点击Android Back按钮时,它不会返回到上一页 .
constructor(private pageRoute: PageRoute) {
super();
this.pageRoute.activatedRoute
.switchMap(activatedRoute => activatedRoute.params)
.forEach((params) => {
this._groupId = params['id'];
this.load(); // this method reload the list in the page.
});
}
我使用不同的URL“home” - >“group / 1” - >“group / 2” - >“group / 3”在同一页面“group /:id”中导航 . 如果我在“group / 3”中单击Android Back Button,我将返回“home” .
我可以在应用程序历史记录中添加“新页面”吗?
谢谢
1 回答
你想要做的是使用CustomRouteReuseStrategy
在您的AppModule中,您希望将其作为提供者
这是play.nativescript.org中的一个例子
https://play.nativescript.org/?template=play-ng&id=AspHuI
(我没有做到这一点,我只是传递了我所学到的信息 . )
此外,如果您只希望某些页面重用路由策略,那么您需要对代码进行其他更改
然后你可以传递noReuse作为路由参数,这样你就可以在默认的“shouldReuse”之外进行额外的检查
希望这可以帮助!