I would like to execute a function inside a ng-repeat to retrieve some other data to show.
For example I've a list of Apartments. I show this list using ng:repeat, than for each Apartment I would like to show the Owner, that is not the u.Apartments. So my getInq function make a call to a service to get the owner of a specified apartment. It seems to be logic for me, but it doesn't work.
It returns the "10 $digest() iterations reached. Aborting!" error.
I've this code:
<div ng:repeat="u in units">
<div ng:repeat="a in u.Apartments">
<div class="targhetta" style="margin-top:10px">{{a.Name}}</div>
<br />{{getInq(a.ApartmentId)}}
<table>
<tr ng:repeat="cs in a.CS">
<td>{{cs.Position}}</td>
<td>{{cs.Code}}</td>
</tr>
</table>
</div>
</div>
And in the controller:
$scope.getInq = function (idApp) {
$http.get('http://localhost:8081/api/registry/GetLastInq?processdata=' + (new Date()).getTime() + '&appartamentoId=' + idApp, { headers: headers })
.success(function (data2) {
$scope.nomeInquilinoVw = data2.Name;
$scope.cognomeInquilinoVw = data2.Surname;
$scope.nomeCognome = $scope.nomeInquilinoVw + " " + $scope.cognomeInquilinoVw;
})
.error(function () {
$scope.success = false;
$scope.error = "There was an error!";
});
return $scope.nomeCognome;
}
Any suggestion?