<分区>
我有 angular2 的问题,当我创建服务并将其附加到 appModule
到 providers:[]
部分时,我有错误:
Uncaught TypeError: Cannot set property 'stack' of undefined
at SyntaxError.set [as stack] (eval at <anonymous> (http://localhost:8080/vendor.js:94:2), <anonymous>:1628:63)
at assignAll (eval at <anonymous> (http://localhost:8080/polyfills.js:2217:2), <anonymous>:704:29)
我做了两个应用程序,但我以前没有遇到过类似的错误... 这是我的简单服务文件:
Injectable()
export class RecordService {
private API_END_POINT: string = 'app/records';
private API = process.env.API_END_POINT;
constructor(private http: Http ) {
}
getRecords(): Observable<any> {
return this.http
.get( this.API_END_POINT )
.map( (res:Response) => res.json().data as RecordModel )
.catch(this.handleError);
}
private handleError(error: any): Promise<any> {
console.error('An error occurred', error);
return Promise.reject(error.message || error);
}
}
我不知道如何解决这个问题,没有关于此错误的任何信息......请寻求帮助!