如何解决Angular 9-输入URL中的加号+问题
我在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 举报,一经查实,本站将立刻删除。