私はメソッドsubscribeを実行すると私の問題が作成され、なぜ私は理解しません。 これは、コードとエラーコンソールで発生している:エラーTypeError:未定義のプロパティ 'property'を設定できません
getInfo(idgestore:number){
let zonaObs=this._zonaservice.getInfoParks(idgestore);
zonaObs.subscribe(data=>{
this.zones=data;
var citta:string;
for(var i=0;i<this.zones.length;i++){
// this.zones[i].citta=null;
this.location.lat=this.zones[i].latitudine;
this.location.lng=this.zones[i].longitudine;
this._zonaservice.getCity(this.location)
.subscribe((data)=>{
citta=data;
})
console.log(this.zones[i].id);
var id_zona=this.zones[i].id;
console.log(id_zona)
this._tipologiazonaservice.getnumberTotal(id_zona)
.subscribe((data)=>{
this.zones[i].numero=data
})
console.log(this.zones)
}
});
}
エラー:
ERROR TypeError: Cannot set property 'numero' of undefined
at SafeSubscriber._next (allinfopark.component.ts:44)
at SafeSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
at SafeSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.next (Subscriber.js:185)
at Subscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125)
at Subscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
at CatchSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125)
at CatchSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
at MapSubscriber.webpackJsonp.../../../../rxjs/operator/map.js.MapSubscriber._next (map.js:83)
at MapSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
at XMLHttpRequest.onLoad (http.es5.js:1226)
サービスコードも共有できますか?ここには「プロパティ」プロパティはありません。 – trichetriche