Non-angular dynamic variable

0

I want to generate a variable dynamically in angularJS with one ng-repeat inside the other as below:

<tr ng-repeat="data in vm.data.data track by $index">
  <td class="center" ng-repeat="field in vm.data.field">         
    {{data + '.' + field}}
  </td>
</tr>

and is printing:

  

[object Object] .name

     

[object Object] .value

where data is an array of objects:

vm.data.data = [{name: 'Teste 1', value: 5311},{ name: 'Teste 2', value: 5245},{ name: 'Teste 3', value: 5236} ,{ name: 'Teste 4', value: 5243}]};

and

// São os campos da tabela, pois eles são dinâmicos
vm.data.field = ['name', 'value'];
    
asked by anonymous 12.02.2016 / 15:09

1 answer

2

Resolved:

<tr ng-repeat="data in vm.data.data track by $index">
  <td class="center" ng-repeat="field in vm.data.field track by $index">
    {{data[field]}}
  </td>
</tr>
    
12.02.2016 / 15:16