Tuesday 20 August 2013

ng-repeat a single element over nested objects

ng-repeat a single element over nested objects

Say I have an object with keys corresponding to products and values
corresponding to objects which in turn have keys corresponding to price
points at which those products have sold, and values corresponding to
amount sold.
For example, if I sold 10 widgets at $1 and 5 widgets at $2, I'd have the
data structure:
{ 'widget': {'1': 10, '2': 5} }
I'd like to loop over this structure and generate rows in a table such as
this one:
thing price amount
---------------------
widget $1 10
widget $2 5
In Python it's possible to nest list comprehensions to traverse lists data
structures like this. Would such a thing be possible using ng-repeat?

No comments:

Post a Comment