how can i show "comment" of this json data in my template ???
(this json comes from ngFor data)
{
"product_id": 2,
"author": 1,
"category": 2,
"title": "python",
"description": "python desc",
"filepath": null,
"price": "50000",
"created_date": "2018-01-28T03:30:00+03:30",
"updated_date": "2018-01-28T03:30:00+03:30",
"product_ratings": {
"p_id": 2,
"commenter": 1,
"comment": "very nice totorial",
"rating": 5,
"created_date": "2018-02-05T03:30:00+03:30"
}
}
i did like below
my component.html
<ul>
<li *ngFor="let data of products">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="http://lorempixel.com/output/technics-q-c-200-200-7.jpg">
</div>
<div class="card-content">
<div>{{ data.title }}</div>
<div>{{ data.description }}</div>
<div *ngFor="let rate of data.product_ratings">{{ rate.comment }}</div>
</div>
</div>
</li>
</ul>
but i get this error:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
when i trying to access comment with :
{{ data.product_ratings.comment }}
i will get
TypeError: Cannot read property 'comment' of null
in browser console
productsan array or an object?