要素を追加するサービスを使用して要素を配列に追加しています。 console.logでデータが入力されているのがわかります配列の要素にアクセスできない
私は要素にアクセスできません。
this.routingService.getNode(startNode).subscribe(node => {
node.forEach(node => {
this.openSet.push(new MapNode(node.id, node.lon, node.lat, this.routingService.getNodeNeighbours(node.id)));
});
});
console.log(this.openSet); // this prints out the below screenshot
私のようなものを使用する場合ただし、:
console.log(this.openSet[0]);
を私は '未定義の' の出力を取得します。私はそれが私はそれにアクセスしているかどうかに今実際に厚いんだか分からない...
アイデア?
あなたがにconsole.log(JSON.stringify(this.openSet))を行うときにあなたが見るものを投稿することができます。 – Sajeetharan
質問にjavascriptタグを追加してください – baao
[非同期呼び出しから応答を返す方法]の可能な複製?(https://stackoverflow.com/questions/14220321/how-to-return-the-response-from-非同期呼び出し) – baao