Angular 2 using nested ngFor

前端 未结 3 648
囚心锁ツ
囚心锁ツ 2021-01-04 08:18

I get this error when using the below code:

Cannot find a differ supporting object \'[object Object]\' of type \'object\'.

Is there any way to workaround thi

相关标签:
3条回答
  • 2021-01-04 08:47

    You loop over an objet not an array , so you should point on that array by swtiching to:

      <div *ngFor="let mem of members.members"> 
    
    0 讨论(0)
  • 2021-01-04 08:57

    Your top level iteration is wrong, the array you want to iterate is inside members.members, so it should be:

      <div *ngFor="let mem of members.members"> // here
        {{mem.id}}
        <div class="card-container">
          <div *ngFor="let case of mem.cases">
            {{case.id}}
          </div>
        </div>
      </div>
    
    0 讨论(0)
  • 2021-01-04 09:06

    change

    <div *ngFor="let mem of members">
    

    to

    <div *ngFor="let mem of members.members">
    
    0 讨论(0)
提交回复
热议问题