How to repeat a JSON object in Angular 2?

Let's say I have this JSON:

{ "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"} ], } 

HTML output should look like this:

 [A] Aa 21 Ab 54 [B] Ba 30 Bb 22 [C] Ca 40 Cb 33 

How can I reuse the angular2 Beta strong> version ?

+5
source share
1 answer

You can use the ng-for directive.

Look at this. angular-2-ng-for-syntax

And you have to convert your object to an array. Take a look here: a-better-way-to-convert-js-object-to-array

+2
source

Source: https://habr.com/ru/post/1240507/


All Articles