I have a call to an API, in which I retrieve various data.
I only want to display some of the fields, so I have created an array with the fields I want to display:
var CamposAPI = ['a','b','c','d','e','f'];
var campo = CamposAPI[i]; (está dentro de un for, según los campos que contenga CamposAPI)
Which I use to then display it with the following line:
$scope.campo = response.data["Clientes"][0][campo];
If I make a console.log, the data is seen correctly, but when binding it, it does not reach the view.
I'm sure I'm doing something wrong in the $scope.field part but I don't see what.
I add the code of the view:
<md-card layout-gt-sm="row" layout-padding ng-controller="MyCtrl">
<table class="table">
<tbody>
<tr>
<td class="text-left"><strong>a</strong></td>
<td class="text-left" colspan="5">{{a}}</td>
</tr>
<tr>
<td class="text-left"><strong>v</strong></td>
<td class="text-left">{{b}}</td>
<td class="text-left"><strong>c</strong></td>
<td class="text-left" colspan="3">{{c}}</td>
</tr>
</tbody>
</mdcard>
All the best.
In this case I think you should do something like this.
You already have the array so the effort of assigning a data in $scope for each one is not necessary. Put the array in $scope and access them by the array.