javascript - View not updating in AngularJS -


i implementing infinite-scrolling in angularjs. below function gets called on successful ajax call, takes place when:

  1. the user scrolls end of screen.
  2. the selects filters, , hits "search" button.

in first case, data fetched ajax call appended existing list. in second case, intend empty existing data in list, , display new data. here code that:

$scope.successcallback=function(data){ $('#spn-model-buffering-image').hide();   //hide loading spinner icon if($scope.providerslist === null) {    $scope.providerslist = []; /* init if null */ } if($scope.scrolled === 'true'){ /*if scroll-end event, append new data existing one*/ array.prototype.push.apply($scope.providerslist, json.parse(data.serviceproviderlist));   //push new data existing list } else{ /*if user clicks on "search providers" button, new data fetched, , occupy entire list view*/ $scope.providerslist=[]; $scope.providerslist=json.parse(data.serviceproviderlist); } viewtobedisplayed(list_view); $scope.scrolled='true'; 

}

so, after successful ajax call, above method called. hides buffering image, , checks if variable named scrolled set true. if yes, means event not button-click, user has reached end of screen, , hence, data have appended. else, user has clicked on button, , hence, data have displayed fresh.

this function gets called on button-click event:

$scope.getfiltereddata=function(){  $scope.scrolled='false';  $scope.getmoredata(); } 

my problem: view not updated. ajax call returns data json. in scroll-event, data fetched , appended existing list, expected. can suggest me might doing wrong? thanks!

here ajax call code:

$scope.getmoredata=function(){   $('#spn-model-buffering-image1').show();   //while data being fetched, display loading spinner   $scope.updateajaxdata();   //update ajax data: pagekey, category, , reftag   var url=$scope.geturl();   a.ajax(url, {       method: 'post',       params: ajax_data,       success: function(data, s, x) {           $scope.successcallback(data);       },       error: function(xhr, statustext, errorthrown) {           $scope.errorcallback(xhr);       }  }); } 

try use http provided angularjs.

$http.get('/someurl', config).then(successcallback, errorcallback); 

this practice , solve problem of not updating view.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -