【发布时间】:2017-10-27 06:14:37
【问题描述】:
检查 URL 中的参数,基于该参数调用其他服务。它在 Chrome/Mozilla/Edge 中按预期工作,但在 IE11 中没有。它不断地重定向到同一个页面。
http://localhost/oauth/?code=xxxxxx
这是我的组件代码。
ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => {
if (params['code']) {
this.loginProcess = 'Hold tight! Authentication in progress.';
this.authenticationService.getOADAccessToken(params['code']).subscribe(function(res){
// some code
});
else {
// redirect to login page
}
它正在获取参数代码值,之后甚至调用 getOADAccessToken 服务调用。但在从服务调用返回之前,它属于else 部分并再次重新加载同一页面,获取参数代码并调用服务并重新加载。
服务.ts
getOADAccessToken(token): Observable<any> {
return this.http.post(environment.API + '/getAccessTokens',
{ code: token })
.map((response: Response) => {
const ADResult = response.json();
return response.json();
});
}
它适用于除 IE10/11 之外的所有浏览器。启用 polyfill.ts 中的所有 polyfill。已启用Intl。
以下是版本详情:
【问题讨论】:
-
我正在使用移动设备,所以我不确定,但您的
if语句缺少右括号} -
@Adrian haha,删除了其他一些行。 '}' 存在于原始代码中
标签: angular angular-cli polyfills