inside a table. If the property is a simple array I can" />

Angularjs ng-repeat : how to display an array of object

angularjs arrays json ng-repeat

708 просмотра

2 ответа

I need to display this values of an property inside an json object with ng-repeat.

"id_products" : [5730827476402176: 2, 5173045979250688: 1, 5735995932672000: 2]

I am using ng-repeat on <tr> inside a table. If the property is a simple array I can display without problems but as the object showed above I am just getting [].

This is a snippet of my code:

        <tr class="animate-repeat" ng-repeat="item in sales|orderBy: 'name'|filter: filter">
          <th> {{item.id_products}}</th>

I tried nested ng-repeats but I get the same result.

What is the right way to display this object?


Автор: Dan Romulus Источник Размещён: 08.11.2019 11:27

Ответы (2)

0 плюса

see the ng-repeat documentation - "The built-in filters orderBy and filter do not work with objects, and will throw an error if used with one.

If you are hitting any of these limitations, the recommended workaround is to convert your object into an array that is sorted into the order that you prefer before providing it to ngRepeat"

Автор: Joe Jadamec Размещён: 20.08.2016 04:25

0 плюса

This object data structure is not javascript or json valid.

Автор: Dan Romulus Размещён: 20.08.2016 05:52
Вопросы из категории :