If you have no idea what this is, please read this :Infinite loop with Angular expression binding
In the html file:
<ui ng-repeat="carrierDetail in carrierDetails">
    <li>
        <i ng-class="{'icon-sign-blank':getStatus(carrierDetail.carrierId)==0,'icon-green':getStatus(carrierDetail.carrierId)==1,'icon-orange':getStatus(carrierDetail.carrierId)==2,'icon-red':getStatus(carrierDetail.carrierId)==3}"></i>
        <ul ng-repeat="owner in getOwners(carrierDetail.carrierId)">
            <li>{{owner.ownerName}}</li>
        </ul>
    </li>
</ui>
As you see, a function getStatus() is called in ng-class and another function getOwners() is called in ng-repeat. And, both functions will call $http service:
$scope.getOwners = function(carrierId) {
    $http.get($scope.baseurl.smart,carrierId,1).then(function(data) {
        return data.data.carrierOwners; // Returns an aray
    }, function(data) {
        return [];
    });
}
$scope.getStatus = function(carrierId) {
    $http.get($scope.baseurl.smart,carrierId,1).then(function(data) {
        return [1, 2, 3].indexOf(data.data.carrierStatus) != -1 ? data.data.carrierStatus : 0; // Returns an integer
    }), function(data) {
        return 0;
    };
}
So, I already know that there are infinite calls for both functions. But I cannot come up with a solution. Maybe I can create a directive for either of the function. But I have no idea how to use the directive in ng-class or ng-repeat.  Are there any simpler ways? Thanks.
 
     
    