0

I am trying to construct a vertical table from JSON data.However my problem is that I have 3 columns,First column is the name of that column.The remaining two columns have to be filled by 2 different arrays.

In this, Vertical ng-repeat question,using same array all columns are being populated,however i want to populate each column with different arrays Here the one column data is about one college and is coming from 1st array,second column should be filled by second array. This is my JSON

{
"result": {
    "college1": [
        {
            "lyr": "0",
            "rating": "",
            "code": "",
            "nirf": "0",
            "mhrd": "0",
            "outlook": "0",
            "tiem": "0",
            "career": "0",
            "naac": "0",
            "fees": "50000",
            "pla": "0",
            "image": "king.jpg"
        }
    ],
    "college2": [
        {
            "lyr": "0",
            "rating": "",
            "code": "",
            "nirf": "0",
            "mhrd": "0",
            "outlook": "0",
            "tiem": "0",
            "career": "0",
            "naac": "0",
            "fees": "25000",
            "pla": "0",
            "image": "king.jpg"
        }
    ]
}

}

Thanks in advance

Shehzadi khushi
  • 275
  • 1
  • 4
  • 20

1 Answers1

0

After working around,the solution i figured out is iterating over key,value pairs of my json array in ng-repeat. I used $index to iterate through second array. This is my code:`

                <tr ng-repeat="(key, value) in college1[0]">

                    <td class="col-md-6 head-field active">{{key}}</td>
                    <td class="col-md-3" ng-repeat="x in data1">
                        {{x[key]}}
                    </td>
                    <td class="col-md-3" ng-repeat="x in data1">
                        {{college2[$index][key]}}
                    </td>
                </tr>

` Just posted the solution so that it might help someone facing similar problem in future :-)

Shehzadi khushi
  • 275
  • 1
  • 4
  • 20