I have created a db in JSON but I can not see the data or get error on the other end but I can se the object in the log.
[ {
"teachers": [
{
"img":"assets/inst/J.png",
"name":"Janine ",
"bio":"lorem"
},{
"img":"assets/insta/I.png",
"name":"Itzhak",
"bio":"lorem"
}
]
}
]
Service for fetching the data
homeds: Home[];
constructor( public dataService: DataProvider) {
this.dataService.fetchData().subscribe(
(data) => {
this.homeds = data}
)
}
Lastly my template file is
<ion-row class="home" *ngFor="let home of homeds">
<img src="{{ home.teachers?.img }}" alt="">
</ion-row>
You should have nested ngFor
since teachers is an array
<ion-row class="home" *ngFor="let home of homeds">
<div *ngFor="let homeobj of home.teachers ">
<img src="{{ homeobj?.img }}" alt="">
</div>
</ion-row>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.