在我的Angular 5应用程序中,我正在做
这样的事情this.returnUrl = this.route.snapshot.queryParams [' returnUrl']
当用户访问路线但我没有登录时,我正在使用它。他被重定向到登录页面,登录后他应该回到这个返回URL。
问题是http://localhost:4200/schedule?selectedDate=2018-01-29访问此路线时,返回网址变为:
http://localhost:4200/login?returnUrl=%2Fschedule%3FselectedDate%3D2018-01-29并且在成功登录后,应用程序尝试转到http://localhost:4200/%2Fschedule%3FselectedDate%3D2018-01-29网址但由于无法识别路径而引发404错误。
知道如何阻止Angular将我的网址更改为此格式?我假设它会选择正确的URL。
答案 0 :(得分:0)
我想你可以简单地添加这样的网址let fruitsArry = ['apple', 'apple, mango, orange', 'orange'];
var res = fruitsArry.join(',').split(',').map(item=>item.trim());
console.log(res);
或者调用点击事件
答案 1 :(得分:0)
使用此功能。
this.returnUrl = decodeURIComponent(this.route.snapshot.queryParams['returnUrl']);
答案 2 :(得分:0)
我设法以某种方式通过而不是使用
来解决这个问题this.router.navigate(this.returnUrl)
我用过
this.router.navigateByUrl(this.returnUrl);