[英]Angular 4 Observable not working in IE11
根據調用其他服務的參數檢查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
部分,然后再次重新加載同一頁,獲取參數代碼,然后調用服務並重新加載。
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();
});
}
它適用於除IE10 / 11之外的所有瀏覽器。 在polyfill.ts
啟用所有polyfill.ts
。 已啟用Intl
。
以下是版本詳細信息:
您正在使用es6-shim嗎? 我幾乎有類似的問題,我使用core.js而不是es6-shim。 如果您想嘗試一下,下面是從es6-shim切換到core.js的示例。
的package.json
//replace es6-shim
"core-js": "2.5.1",
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.