Angular2 *ngFor: “Cannot read property '0' of undefined”

前端 未结 3 1485
情歌与酒
情歌与酒 2021-01-05 19:06

I trying to get data from a JSON file to build a form.

Here is a portion of my template:

  
3条回答
  •  囚心锁ツ
    2021-01-05 20:04

    I guess what you want is

    *ngFor="let p of heroes?.data"
    

    because heroes seems to be an object, and ngFor can only iterate array. The level property also is in an array item.

提交回复
热议问题