Let's say I have a JSON like this:
{
"A": [
{"name": "Aa", "count": "21"},
{"name": "Ab", "count": "54"}
],
"B": [
{"name": "Ba", "count": "30"},
{"name": "Bb", "count": "22"}
],
"C": [
{"name": "Ca", "count": "40"},
{"name": "Cb", "count": "33"}
],
}
Output HTML should like this:
[A]
Aa 21
Ab 54
[B]
Ba 30
Bb 22
[C]
Ca 40
Cb 33
How can I iterate using angular2 Beta version?
You can use the ng-for directive.
Have a look at this. angular-2-ng-for-syntax
And you should convert your object to an array. Have a look here: a-better-way-to-convert-js-object-to-array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With