未捕获的ReferenceError:__ng_jsonp____req0_finished在以下位置未定义 [英] Uncaught ReferenceError: __ng_jsonp____req0_finished is not defined at

查看:75
本文介绍了未捕获的ReferenceError:__ng_jsonp____req0_finished在以下位置未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Angular应用程序,我也在使用JSONP.

I have an Angular application and I'm using JSONP as well.

这是我的服务

import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Page } from './page';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { Jsonp } from '@angular/http';

@Injectable()
export class ProductService {

    private urlPage = 'http://api.zanox.com/json/2011-03-01/products?q=iphone&connectid=XXXXXXXXXXXX&programs=12011&callback=JSONP_CALLBACK';

    constructor(private _jsonp: Jsonp) { }

    getPage(): Observable<Page> {
        return this._jsonp.get(this.urlPage).map(this.extractData).catch(this.handleError);
    }

    private extractData(res: Response) {
        let body = res.json();
        return body || {};
    }

    private handleError(error: any) {
        let errMsg = (error.message) ? error.message :
            error.status ? `${error.status} - ${error.statusText}` : 'Server error';
        console.error(errMsg);
        return Observable.throw(errMsg);
    }

}

我收到此错误:

未捕获的ReferenceError:__ng_jsonp____req0_finished未定义 在产品上吗?q = iphone& connectid = XXXXXXXXXX& programs = 12011& callback = __ ng_jsonp ____ req0_finished:1

Uncaught ReferenceError: __ng_jsonp____req0_finished is not defined at products?q=iphone&connectid=XXXXXXXXXX&programs=12011&callback=__ng_jsonp____req0_finished:1

(匿名)@ 产品?q = iphone& connectid = XXXXXXXXXXXX& programs = 12011& callback = __ ng_jsonp ____ req0_finished:1 common.js:143

(anonymous) @ products?q=iphone&connectid=XXXXXXXXXXXX&programs=12011&callback=__ng_jsonp____req0_finished:1 common.js:143

未捕获的TypeError:无法读取null的属性"apply" 在globalOnerror(common.js:143)

Uncaught TypeError: Cannot read property 'apply' of null at globalOnerror (common.js:143)

globalOnerror @ common.js:143

globalOnerror @ common.js:143

productService.ts:29 200-好

productService.ts:29 200 - Ok

如何解决?

推荐答案

我解决了该错误,可以回溯到Angular的2.3.1版本.该错误发生在2.4.X版本中.

I solved this bug going back to the version 2.3.1 of Angular. The bug happens in the version 2.4.X.

"@angular/common": "~2.3.1",
"@angular/compiler": "~2.3.1",
"@angular/core": "~2.3.1",
"@angular/forms": "~2.3.1",
"@angular/http": "~2.3.1",
"@angular/platform-browser": "~2.3.1",
"@angular/platform-browser-dynamic": "~2.3.1",
"@angular/router": "~3.3.1",

这篇关于未捕获的ReferenceError:__ng_jsonp____req0_finished在以下位置未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆