关于angularjs的ng-repeat与获取json的问题

问题是这样的,我有两组数据存在两个json中,一组叫relationship存了好友关系,(主id,好友id...)
另一组叫user,存了用户信息(id,name,.....),现在我想将好友的id和name都展示出来,一开始
我在controller中先用$http取得relationship的json,然后用ng-repeat列表展示好友id,
但是我不知道怎么通过好友id取得用户信息的name同时展示出来,部分代码如下。

  .controller("friendCtrl",function($scope, $ionicPopup,$location,$http) {
    $http.get(url).then(function  
            successCallback(response){
            $scope.names = response.data.Relationship;
        },function errorCallback(response){
            alert("读取错误");
            $location.path('/friend');
        })


                $scope.getName= function(id){
                            $http.get(url).then(function  successCallback(response){
                                        $scope.names1 = response.data.User;
                                        return response.data.User[0].name;
                            },function errorCallback(response){
                                        alert("读取错误");
                                      $location.path('/friend');
                                        return 0;
        })
                }
}

<html>
<div class="list">
            <label class="item item-input item-stacked-label" ng-repeat="x in names">
                <span>{{x.object}}</span>
                                 <span>{{getName(x.object)}}</span>
            </label>
        </div>
    </html>

relationship(subject,object) User(id,name) subject,object都是user中的id
我一开始想{{getName(x.object}},然后写个函数来获取name,但是会引发脏读循环
,而且$http的异步问题不能return数据,请问有什么方法来获得name?

https://segmentfault.com/q/1010000005932840

从服务器获取到users数据后,转化成hash,用户id为键,用户对象为值。

从服务器获取到users数据后,转化成hash,用户id为键,用户对象为值。
如:

usersHash  ={
        1: {
                uid: 1,
                uname: '张三',
        },
        2: {
                uid: 2,
                uname: '李四',
        }
};

// 然后就是取值了:
userHash[好友id].uname

最好后台再提供一个接口,把这两个接口的response合并;
或者试一试:{{}}里面不要调用方法,只是引用对象,然后在$http.get(url).then(//get relationship).then(//get name from relationship)去构造引用的对象