3
タイプに存在しません:Angular2プロパティは、私が命名<strong>条件</strong>クラスを持っている 'は任意の[]'(JSON)
export class Condition{
name: string;
date: string;
link: string;
}
そして、HTTP GETリクエストになり検索という名前の関数:
を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'));
}
そして、特定のプロパティを持つ条件を取得するオブジェクトを取得します。私は起動スクリプトでこれらのコードを書いた前に、私はこれらのプロジェクトを開始しました
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); });
:それは、そのエントリで属性を絶対にオブジェクト配列を持つ
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
そしてプロジェクトは、私のように働いていましたコンソール上にエラーが表示されませんでした。私はそれを停止し、起動スクリプトを再び始めたときしかし、それはこのエラーを与える:
error TS2339: Property 'entry' does not exist on type 'any[]'.
は、あなたはそれと間違っているものを知っていますし、どのように私はそれを修正することができますか?
はい、私はそれのタイプを変更するのを忘れました。ありがとうございました! –