vishal vishal - 5 months ago 8
AngularJS Question

How can i use ng-repeat inside ng-repeat but inner ng-repeat should print one value of an array at a time

In the code below,

mydt
data is coming from a json and
chkdur
data is coming from a different array. I want to print the
mydt
and
chkdur
values simultaneously...

My Code

<tr ng-repeat="sdetail in mydt">
<td>{{sdetail.pmsg}}</td>
<td>{{sdetail.displaytime}}</td>
<td ng-repeat="st in chkdur">{{st}}</td>
</tr>

Answer

You should use $index to print respective json data from second array

<tr ng-repeat="sdetail in mydt">
                    <td>{{sdetail.pmsg}}</td>
                    <td>{{sdetail.displaytime}}</td>
                    <td>{{chkdur[$index]}}</td>
</tr>
Comments