Im trying to show a loading block when the infinite scroll is loading more list items, and its ok for the first time, but the followings does'nt work. When "$scope.isLoading = true;" the block is not visible.
HTML
<ons-scroller infinit-scroll-enable="true" on-scrolled="getNextItems()" threshold="20" style="height:100%">
<ons-list-item ng-repeat="i in items" modifier="tappable chevron">{{i.name}}</ons-list-item>
<ons-list-item ng-show="isLoading"> LOADING </ons-list-item>
</ons-scroller>
JAVASCRIPT
$scope.getNextItems = function(){
if($scope.isLoading) return;
$scope.isLoading = true;
setTimeout(function(){
$scope.$apply(function(){
addItems($scope.items);
$scope.isLoading = false;
});
},3000);
};
Here is the fiddle with the problem.
I tried different ways to do this, but always the same result.
Thanks in advance!!
As @rohan answers the problem is solved with $timeout and the behavior that i want is like this:
http://jsfiddle.net/hasukronos/mh6roxsk/1/
But i forgot to mention that the real problem happens with WebSQL api callback that have the same problem as native setTimeout.