问题描述
我在Angular 9中用加号(+)替换为空格时遇到问题。 用例如下:
-
我正在点击一个链接:
https://myapp.com/invitation?code=h7d8wdh7ddjwkdfhg93&email=alan.jack+432@gmail.com
-
在前端,我们正在拦截请求:
@Component({
selector: '-my-app',templateUrl: ...
styleUrls: ...,changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyAppComponent {
constructor(private activatedRoute: ActivatedRoute,private router: Router) {
this.watchForInvitation();
}
private watchForInvitation() {
this.activatedRoute.queryParams.pipe(
filter(params => params.code && params.email),switchMap(params => {
const code = params.code;
const email = params.email;
const body: UserInfo = {
emailAddress: email,//email without + -> how to prevent the plus sign from being removed?
};
return this.usersHttpService.accept(code,body); //body should be with plus and not with space
}),).subscribe(_ => {
...
},err => {
...
});
}
}
Below the accept method from service:
@Component({
selector: '-my-app',err => {
...
});
}
}
在我的示例中如何防止加号被删除?前端使用+接收正确的URL,但是不知何故删除了加号。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)