How to correct write ionic controller?
<p>Hello i have some problem with my controller. I try to get friends from Buddypress with JSON API. Its <a href="http://hannation.me/api/buddypressread/friends_get_friends/?username=adminara&amp;insecure=cool" rel="nofollow">http://hannation.me/api/buddypressread/friends_get_friends/?username=adminara&amp;insecure=cool</a> </p>

<p>But when im trying to get this in my application it was doesn't work.</p>

<p>This is my Controller 
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// Friends Controller
.controller('FriendsCtrl', function($scope, $rootScope, $state, $ionicLoading, PostService) {
  $scope.posts = [];
  $scope.friends = [];
  $scope.page = 1;
  $scope.totalPages = 1;

  $scope.doRefresh = function() {
    $ionicLoading.show({
      template: 'Loading posts...'
    });

    //Always bring me the latest posts =&gt; page=1
    PostService.getUserFriends(1)
    .then(function(data){

      $scope.totalPages = data.pages;
      $scope.posts = PostService.shortenPosts(data.posts);

      $ionicLoading.hide();
      $scope.$broadcast('scroll.refreshComplete');
    });
  };

  $scope.loadMoreData = function(){
    $scope.page += 1;

    PostService.getUserFriends($scope.page)
    .then(function(data){
      //We will update this value in every request because new posts can be created
      $scope.totalPages = data.pages;
      var new_posts = PostService.shortenPosts(data.posts);
      $scope.posts = $scope.posts.concat(new_posts);

      $scope.$broadcast('scroll.infiniteScrollComplete');
    });
  };


  $scope.doRefresh();

})</code></pre>
</div>
</div>
</p>

<p>This is my Service 
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>  this.getUserFriends = function(friends){
    var deferred = $q.defer();

      $http.jsonp(WORDPRESS_API_URL + 'buddypressread/friends_get_friends/?username=adminara' +
    '&amp;insecure=cool' +
      '&amp;type=full' +
      '&amp;callback=JSON_CALLBACK')

  .success(function(data) {
      deferred.resolve(data);
    })
    .error(function(data) {
      deferred.reject(data);
    });

    return deferred.promise;
  };</code></pre>
</div>
</div>
</p>

<p>This is my HTMl </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>    &lt;ion-list ng-repeat="friend in friends"&gt;
      &lt;ion-item&gt;
        &lt;ion-avatar item-left&gt;
          &lt;img class="friends-avatar" src="{{friend.avatar}}"&gt;
        &lt;/ion-avatar&gt;
        &lt;h2&gt;{{friend.friends.username}}&lt;/h2&gt;
        &lt;h3&gt;{{friend.mail}}&lt;/h3&gt;
      &lt;/ion-item&gt;
    &lt;/ion-list&gt;</code></pre>
</div>
</div>
</p>

<p>What wrong with my code? Where is error? </p>