0

Return object looks like this

data: { "23":
       { prop: abc, prop_2: def },
        "78":
       { prop: abc, prop_2: def },
       "2098":
       { prop: abc, prop_2: def },
      }

Code

<div *ngFor="let filterCar of data">
     // blah blah
  </div>
1
  • You are trying to iterate over JSON object, and not Array. You should transform your object to an array of objects if you want to use *ngFor. Commented Jul 12, 2018 at 11:49

2 Answers 2

1

You should transform your object into an array of object with Object.values :

let tab = Object.values(data);

And then you can iterate over it with ngFor

<div *ngFor="let filterCar of tab">
 // blah blah
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

You can't call *ngFor on Object, just array, you should transform your object into an array of your object with Object.entries :

const arrayOfObject = Object.entries(data);

And then you can iterate over new variable with *ngFor

<div *ngFor="let item of arrayOfObject "></div>

MDN Object.entries()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.