admin管理员组文章数量:1303335
I have a class named Condition:
export class Condition{
name: string;
date: string;
link: string;
}
And a function named search that makes http get requests:
public search(params: string): Observable<json[]> {
let queryString = this.serverUrl + params;
return this.http.get(queryString)
.map((res:Response) => res.json())
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
And I get an object to get conditions with specific properties from it. It has absolutely an object array in its entry attribute:
this.search(`Condition?patient=Patient/107795`).subscribe(data => {
var conditionArray = data.entry; // data.entry is absolutely an ARRAY
for(var condition of conditionArray){
conditions.push({ //conditions is a Condition[]
name: condition.resource.code.coding[0].display,
date: condition.resource.dateRecorded,
link: "condition/" + condition.resource.id
});
}
} , err => { console.log(err); } );
I was started these project before I wrote these code with start script:
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
And the project was working as I wanted and no error on the console. However, when I stopped it and started again with the start script, it gives this error:
error TS2339: Property 'entry' does not exist on type 'any[]'.
Do you know what is wrong with it and how can I fix it?
I have a class named Condition:
export class Condition{
name: string;
date: string;
link: string;
}
And a function named search that makes http get requests:
public search(params: string): Observable<json[]> {
let queryString = this.serverUrl + params;
return this.http.get(queryString)
.map((res:Response) => res.json())
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
And I get an object to get conditions with specific properties from it. It has absolutely an object array in its entry attribute:
this.search(`Condition?patient=Patient/107795`).subscribe(data => {
var conditionArray = data.entry; // data.entry is absolutely an ARRAY
for(var condition of conditionArray){
conditions.push({ //conditions is a Condition[]
name: condition.resource.code.coding[0].display,
date: condition.resource.dateRecorded,
link: "condition/" + condition.resource.id
});
}
} , err => { console.log(err); } );
I was started these project before I wrote these code with start script:
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
And the project was working as I wanted and no error on the console. However, when I stopped it and started again with the start script, it gives this error:
error TS2339: Property 'entry' does not exist on type 'any[]'.
Do you know what is wrong with it and how can I fix it?
Share Improve this question asked Sep 7, 2016 at 7:46 Bünyamin SarıgülBünyamin Sarıgül 3,0914 gold badges34 silver badges56 bronze badges1 Answer
Reset to default 6Your search
method should probably return an object, not an array. Declare it as follows:
public search(params: string): Observable<any> {
Use any
unless you have a type describing the result, if so, you may use that instead.
本文标签: javascriptAngular2 Property does not exist on type 39any39 (JSON)Stack Overflow
版权声明:本文标题:javascript - Angular2 Property does not exist on type 'any[]' (JSON) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741725686a2394607.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论