私はレシピのウェブアプリを持っている、と私は子コンポーネントと「レシピを追加する」のページを持ってここに見られるように「成分を追加」入れ子にし、そのHTML内で呼び出さ:サービスから受信したが、それを反復できない配列オブジェクト?
<h2>Add {{addRecipeForm.controls.name.value}}</h2>
<form [formGroup]="addRecipeForm">
...
<app-add-ingredient></app-add-ingredient>
<hr>
<button type="submit">Add new recipe</button> <button (click)="goBack()">Back</button> <button (click)="test()">check if array was caught</button>
</form>
<p>Recipe ingredient list (from service)</p>
<div *ngIf="ingredientList">
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Quantity</th>
<th>Units and Style</th>
</tr>
<tr *ngFor="let ingre of ingredientList">
<td>{{ingre.ID}}</td>
<td>{{ingre.name}}</td>
<td>{{ingre.quantity}}</td>
<td>{{ingre.unitsAndStyle}}</td>
</tr>
</table>
</div>
私は、その後にボタンを追加しましたサービスから送信されたデータが実際に正しいフォーマットで受信されていることを確認します(子コンポーネントが要素を追加したときにオブジェクトを完全に送信するスクリーンショットに見られるように)が、エラー:
私の 'test()'関数はスクリーンショットに見られるように配列とそのすべてを記録するだけなので、サービスは問題ではないことが分かります。
は、コンソールウィンドウのスクリーンショットに示すいくつかの配列があるようになっているのですか?私はname = 'fawf'、ID = 20のオブジェクトを参照しますが配列はありません。配列は、角カッコではなく、角カッコで表示されます。 –