这过去工作在角2/4,但自从我升级到角7,我得到这个错误在整个我的应用程序。突然间会有什么问题?
Type 'Observable<Observable<Object[]>>' is not assignable to type 'Observable<Object[]>'
Type 'Observable<Object>' is not assignable to type 'Observable<object[]>'.
Type 'Object' is not assignable to type 'object[]'.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
Property 'includes' is missing in type 'Object'.我试过使用“任意”类型,但仍然存在相同的错误。
受影响的守则:
getProfiles(): Observable<any[]> {
const _url: string = this._serviceUrl + 'api/GetUserProfiles/';
return this._http.get(_url)
.catch(this.handleError);
}呼叫方方法
this._exceptionService.getProfiles().subscribe(data => {
this.data = data[0];
}package.json
"@angular/animations": "^7.0.0",
"@angular/cdk": "^7.0.0",
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.0",
"@angular/core": "^7.0.0",
"@angular/forms": "^7.0.0",
"@angular/http": "^7.0.0",
"@angular/material": "^7.0.0",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",发布于 2018-10-22 20:39:34
我以前遇到过这个问题。更改您的可观察值以返回任何
删除数组括号[]
getProfiles(): Observable<any> {
const _url: string = this._serviceUrl + 'api/GetUserProfiles/';
return this._http.get(_url)
.catch(this.handleError);
}https://stackoverflow.com/questions/52936310
复制相似问题