angularjs - ng-repeat model.array[0].otherArray -


this questions in relation question of mine; angularjs-multi-level-tables-inside-another-if-clicked. (you can see "full" json there.)

why can't have ng-repeat below?

<tbody> <tr data-ng-repeat="daydata in storedatamodel.storedata[0].data">   <td>{{daydata.date}}</td>   <td>{{daydata.cost}}</td>   <td>{{daydata.sales}}</td>   <td>{{daydata.revenue}}</td>   <td>{{daydata.employees}}</td>   <td>{{daydata.employeehourssum}}</td> </tr> </tbody> 

angular finds number of objects in array "daydata" particlar "store" (the storedata[0] first store) reason creates n+1 rows instead of n , there's no data @ in of rows.

i have tried lot of combinations, trying make work...:

  • storedatamodel.storedata.data -returns no rows @ all
  • storedatamodel.storedata.$index.data -returns no rows @ all
  • storedatamodel.storedata.$index+1.data -returns errors
  • storedatamodel.storedata.$first.data -returns no rows @ all

is trying possible @ or need write directive specific store daydata information , put in temporary model specific store , ng-repeat on temporary model?

(also, trying particular table content "fake accordion", i.e. when clicking row in parent table expand/collapse , show particular table (see linked question) - there non-compatibilities if include ng-clicked or own directive proposed solution?)

in ng-repeat, have iterate on array. in json, "data" object :

{   "data": {      ...      "daydata" : [        ...      ]    }  } 

so, have iterate on "daydata" :

<tbody> <tr data-ng-repeat="daydata in storedatamodel.storedata[0].data.daydata">   <td>{{daydata.date}}</td>   <td>{{daydata.cost}}</td>   <td>{{daydata.sales}}</td>   <td>{{daydata.revenue}}</td>   <td>{{daydata.employees}}</td>   <td>{{daydata.employeehourssum}}</td> </tr> </tbody> 

you can see on fiddle


Comments