AngularJS, show array value according to another array current position

  Kiến thức lập trình

In javascript, there are two arrays, their length are equal, but the length is not known, based on some db value. for example

colName=['col1','col2','col3'];
fieldValue=['abc','def','ghi'];

or

colName=['col1','col2','col3', 'col4'];
fieldValue=['abc','def','ghi', 'lmn'];

or
colName.length = x, fieldValue.length = x

where x is variable.

then in html, using angularjs I want to display the colName value based on the position of current retrieving fieldValue position.

e.g.

<tr ng-repeat="fieldValue in form.fieldValue track by $index">
    <td> {{colName[{{$index}}]}}</td>
    <td> {{fieldValue}} </td> 
</tr>

Of course this part is fail

<td> {{colName[{{$index}}]}}</td>

so how to show the colName[x] based on the current fieldValue position?

Expected Result: (no.of colX is dynamic)

col1 abc
col2 def
col3 ghi

LEAVE A COMMENT