我将角度库升级到4.3.6,将tslint升级到5.7.0,在构建角度应用程序时出现以下错误。
我在下面的代码中没有使用RequestOptionsArgs,但我收到以下错误
错误
Type 'Headers' has no properties in common with type 'RequestOptionsArgs'.
我的角度服务代码如下
import { Injectable } from '@angular/core';
import {Summary} from './summary';
import {Http, Headers, Response} from '@angular/http';
import { Observable } from 'rxjs/Observable';
import {SelectItem} from "primeng/primeng";
import {ExceptionHandle} from "../util/exceptionhandle";
import {MYCONST} from "../util/constants";
@Injectable()
export class MyService {
private myUrl= MYCONST.reconURL.url;
private headers: Headers = new Headers({"Content-Type'" : 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Credentials':'true'
});
getSummaries(): Observable<Summary[]> {
return this.http.get(this.reconUrl + '/summaries', this.headers)
.map((response: Response) => <Summary[]> response.json())
.catch(this.handleError);
}
private handleError(error: any): Promise<any> {
return ExceptionHandle.handleError(error);
}
}
答案 0 :(得分:0)
您在错误的位置传递了headers
参数。您应该在http.get
方法
headers
作为RequestOptionsArgs
对象的属性传递
return this.http.get(this.reconUrl + '/summaries', { headers: this.headers })