Here is an example of JSON data:
[
{
"id": 1,
"name": "Vojislav Kovacevic",
"street": "Sava Burica",
"city": "Belgrade",
"state": "Zemun",
"zip": "11080",
"country": "Serbia",
"giftwrap": null,
"products": "[
{\"count\":2,\"id\":1,\"price\":275,\"name\":\"Kayak\"},
{\"count\":1,\"id\":2,\"price\":48.95,\"name\":\"Lifejacket\"}
]"
},
{
"id": 2,
"name": "dzimi",
"street": "dzimi strit",
"city": "belgrade",
"state": "zemun",
"zip": "11000",
"country": "serbia",
"giftwrap": null,
"products": "[
{\"count\":5,\"id\":1,\"price\":275,\"name\":\"Kayak\"},
{\"count\":3,\"id\":2,\"price\":48.95,\"name\":\"Lifejacket\"},
{\"count\":4,\"id\":3,\"price\":19.5,\"name\":\"Soccer Ball\"}
]"
},
{
"id": 3,
"name": "mimi",
"street": "cincar janka 7",
"city": "novi sad",
"state": "novi sad",
"zip": "11000",
"country": "serbia",
"giftwrap": null,
"products": "[
{\"count\":2,\"id\":1,\"price\":275,\"name\":\"Kayak\"},
{\"count\":1,\"id\":2,\"price\":48.95,\"name\":\"Lifejacket\"}
]"
}
]
When looping through this data with the following code:
<tr ng-repeat="order in orders">
<td>{{ order.products.length }}</td>
</tr>
The output is 100, 153, 100
, but it should be 2, 3, 2
since each object contains a certain number of items in the products
array.