i trying pass data json feed html file, below not working.
app.component.html
<ul *ngfor="let unit of units"> <li> {{unit.details.count}} // getting data ok result -> 5642 </li> <li> {{unit.cars.vehicle_id}} // not getting data </li> </ul>
units_feed.json
[{"details":{"count":"5642"},"cars":[{"vehicle_id":"2056437754"},{"vehicle_id":"2056437753"},{"vehicle_id":"2056356347"},{"vehicle_id":"2056437752"},{"vehicle_id":"2056395634"}]}]
you cant access unit.cars
array of object. if wanted access 1 of objects i.e. ones vehicle_id
use {{unit.cars[0].vehicle_id}}
. notice [0]
telling access first item in array , can view property vehicle_id
.
would guess have this
<ul *ngfor="let unit of units"> <li> {{unit.details.count}} </li> <li *ngfor="let car of unit.cars">{{car.vehicle_id}}</li> </ul>
Comments
Post a Comment