title: Ionic list infinite scroll issue with assync request
body: <p>I have a problem with Ionic list filled by assync request. </p>
  
  <p>In HTML I have following:</p>
  
  <pre><code>&lt;ion-list class="list" ng-init="setDateRange('today');" &gt;
            &lt;!--IF NO ITEM IS FOUND --&gt;
            &lt;ion-item class="listCenter" ng-if="listData.length == 0 || listData.length == null"&gt;
                &lt;h2&gt;No data found, try to make few calls&lt;/h2&gt;
            &lt;/ion-item&gt;
  
            &lt;ion-item class="item" ng-repeat="listDataItem in listData"&gt;
            &lt;!--HTML CONTENT OF ITEM REMOVED FROM EXAMPLE --&gt;
            &lt;/ion-item&gt;
  
            &lt;ion-infinite-scroll
                    icon="ion-loading-c"
                    distance="10%"
                    on-infinite="setDateRange('past')"&gt;
            &lt;/ion-infinite-scroll&gt;
   &lt;/ion-list&gt;
  </code></pre>
  
  <p>In ng-init is called method setDateRange method which is triggering assync request in separated method on the database.</p>
  
  <p>I think, that problem could be in implementation of the $broadcast methods <strong>scroll.infiniteScrollComplete</strong> in updateList and createList, which are following.  </p>
  
  <pre><code>$scope.updateList = function() {
              console.log('Trying to update list');
              $timeout(function() {
                  $scope.$apply(function() {
                      listData.forEach(function(item){
                          $scope.listData.push(item);
                          console.log("List length is "+ $scope.listData.length);
                      });
                      $ionicLoading.hide();
                  });
                  $scope.$broadcast('scroll.infiniteScrollComplete'); // should be removed in production
                  $scope.$broadcast('scroll.resize');
              });
          };
  
          $scope.createList = function() {
              console.log('Trying to render list');
              alert("render");
              $timeout(function() {
                  $scope.$apply(function() {
                      $scope.listData = listData;
                      console.log("List length is "+ $scope.listData.length);
                  });
                  // Infinite scroll broadcast should be here to avoid
                  // triggering of the on-infinite event
                  $scope.$broadcast('scroll.infiniteScrollComplete');
              });
              $ionicLoading.hide();
          };
  </code></pre>
  
  <p>Because during the ng-init is also triggered method updateList which cannot be done because $scope.listData does not exist at this moment. </p>
  
  <p>Could somebody tell me how to implement </p>
  
  <pre><code>$scope.$broadcast('scroll.infiniteScrollComplete') 
  </code></pre>
  
  <p>and </p>
  
  <pre><code> $scope.$broadcast('scroll.resize');
  </code></pre>
  
  <p>In right way?</p>
  
  <p>Thanks for any help. </p>