简体   繁体   English

Angular 4 Observable在IE11中不起作用

[英]Angular 4 Observable not working in IE11

Checking param in URL, based on that param calling some other service. 根据调用其他服务的参数检查URL中的参数。 It's working as expected in Chrome/Mozilla/Edge but not in IE11. 它可以在Chrome / Mozilla / Edge中正常运行,但在IE11中却无法正常运行。 It's continuously redirecting to the same page. 它不断重定向到同一页面。

http://localhost/oauth/?code=xxxxxx

and here are my component code. 这是我的组件代码。

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
  }

It's getting param code value, after that even its calling getOADAccessToken service call. 在获取参数代码值之后,甚至调用了getOADAccessToken服务。 But before return from service call its falls to else part and again reloading the same page, getting param code and calling service and reloading. 但是在从服务返回之前,调用它的else部分,然后再次重新加载同一页,获取参数代码,然后调用服务并重新加载。
service.ts service.ts

getOADAccessToken(token): Observable<any> {
    return this.http.post(environment.API + '/getAccessTokens',
        { code: token })
        .map((response: Response) => {
            const ADResult = response.json();
            return response.json();
        });
}

It's working in all browsers except IE10/11. 它适用于除IE10 / 11之外的所有浏览器。 Enabled all polyfills in polyfill.ts . polyfill.ts启用所有polyfill.ts Enabled Intl . 已启用Intl
Here are the version details: 以下是版本详细信息:
在此处输入图片说明

Are you using es6-shim? 您正在使用es6-shim吗? i have almost similar issues and i swithc to core.js instead of es6-shim. 我几乎有类似的问题,我使用core.js而不是es6-shim。 Below is sample to switch from es6-shim to core.js if you wanna gv it a try. 如果您想尝试一下,下面是从es6-shim切换到core.js的示例。

package.json 的package.json

//replace es6-shim
    "core-js": "2.5.1",

html HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.5.1/core.min.js"></script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM