[英]How to change the dropdown value, if we have more records without having break using angular8
[英]How to change the value of the url without refreshing the page in angular8
我已经使用 window.open 在新标签中打开页面,在新标签中,从主屏幕我有一个编辑和查看选项,所以如果我点击 url 中的视图,我将传递 1,然后点击编辑我传递 2,所以我传递的总共 3 个值,带有 2 个代码。 现在,当我点击主页上的查看按钮时,我得到这样的网址:
http://localhost:4200/data?dt=1211-1211-1
所以,在视图中我有一个编辑按钮,它允许所有字段进行编辑,所以在这里我希望我的 url 是
http://localhost:4200/data?dt=1211-1211-2,
因此,它将处于编辑模式。 我已经使用激活的路由器从主页面到新选项卡的 url 中获取值
let url = this.route.snapshot.queryParams.dt.split("-");
this.gp= url[0];
this.ap = url[1];
this.mode = url[2];
您可以使用新的查询参数导航到当前路线,这不会重新加载您的页面,但会更新查询参数
editMode(){
const queryParams = this.gp.toString() + this.ap.toString() + '2';
this.router.navigate(
[],
{
relativeTo: this.route,
queryParams: queryParams,
queryParamsHandling: 'merge'
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.