-2

I have a json object under array Frequency till index 9 Frequency

{cou: "IND", cur :"INR", val:"15"}  
{cou: "US", cur :"DOL", val:"65"}  
{cou: "ENG", cur :"PND", val:"75"}    
{cou: "IND", cur :"RUPEES", val:"15"}  
{cou: "US", cur :"DOLLAR", val:"15"}  
{cou: "ENG", cur :"POUND", val:"15"}  
{cou: "IND", cur :"R", val:"15"}  
{cou: "US", cur :"D", val:"15"}  
{cou: "ENG", cur :"P", val:"15"}  

I have to show the value of currency i.e "cur" in 3 different columns of a table in same order as below(1st 3 in 1st col,next 3 in 2nd col and last 3 in 3rd).

INR RUPEES R  
DOL DOLLAR D  
PND POUND P  

I have got data in object in controller in "$ctrl.ndata" upto index 3, in $ctrl.sdata upto index 4 to 6 and in $ctrl.pdata from index 7 to 9.

here is my view code.

<table class="datatable bold">  
<thead><tr>  
<th>CUR1</th>  
<th>CUR2</th>  
<th>CUR3</th>  
</tr></thead>  
<tbody>  
<tr ><td ng-repeat="i in $ctrl.ndata">{{i.cur}}</td>  
     <td ng-repeat ="i in $ctrl.sdata">{{ i.cur}}</td>  
     <td ng-repeat ="i in $ctrl.pdata">{{ i.cur}}</td>  
</tr></tbody>  
</table>  

But I am getting data in on column same row. can somebody help. Thanks

Saket
  • 1
  • you should only use ng-repeat for `$ctrl.ndata` and from child node make a call to function that refers to sdata & pdata based on `cou` . – super cool Feb 20 '18 at 10:18

1 Answers1

0

Try something like this:

<tr ng-repeat="n in [0,1,2]">
  <td ng-repeat="i in $ctrl.ndata" ng-if="$index % 3 == 0">{{i.cur}}</td>
</tr>
Veselin Kontić
  • 1,638
  • 2
  • 11
  • 23