Question from the Ionic Framework test

Create an Ionic app that loads items when the user scrolls down and displays items when the view loads.

Hard

Here is the code for a view of our Ionic application :

<ion-content ng-controller="MyController">
  <ion-list>
      <ion-item ng-repeat="item in items">
         {{item}}
      </ion-item>
  </ion-list>
 
  <ion-infinite-scroll on-infinite="loadItems()" icon="ion-loading-c"></ion-infinite-scroll>
</ion-content>
function MyController($scope, $http) {
  $scope.items = [];

  $scope.loadItems = function () {
    $http.get('/items').then(function (items) {
      items.forEach(function (item) {
          $scope.items.push(item);
      });
    });
  };

  $scope.$on('$stateChangeSuccess', function () {
    $scope.loadItems();
  });
}

What will happen ?

Author: Benjamin CanacStatus: PublishedQuestion passed 132 times
Edit
1
Community EvaluationsNo one has reviewed this question yet, be the first!