2

I am new to angular. In my single page web app, I have two tabs with ng-infinite-scroll in each of them. The two tabs are traversed between using a nav-bar,

    <div ng-show="$state.includes('base.videolist')||$state.includes('base.movielist')  ">
<ul class="nav navbar-fixed-top roboto nav-tabs">
   <li ui-sref="base.videolist" ui-sref-active="active"><a>Videos</a></li>
   <li ui-sref="base.movielist" ui-sref-active="active"><a>Movies</a></li>
</ul>
</div>

and each tab resides in two ui-views as shown below.

<div id="bvl" ui-view="videolist" ng-show="$state.includes('base.videolist')"></div>
<div id="bml" ui-view="movielist" ng-show="$state.includes('base.movielist')"></div>

When using ng-show, the height of the hidden div is set to 0 by angular. thereby triggering the infinite-scroll infintely.

I dont want to use ng-if because i want to maintain the scroll state of the lists.

How to handle this?

PS. i use sticky states for both the lists to maintain states between master detail view of the list elements.

55597
  • 1,705
  • 1
  • 17
  • 37

1 Answers1

2

from https://sroze.github.io/ngInfiniteScroll/documentation.html

infinite-scroll-disabled (optional) - {boolean} - A boolean expression that, when true, indicates that the infininite scroll expression should not be evaluated even if all other conditions are met.

If you want to use ng-show="showIt" to hide an element containing an infinite scroll, you can add infinite-scroll-disabled="!showIt" to stop it from trying to load more items while hidden.

Here is a jsbin example with 2 infinite scrolling divs that can each be hidden with ng-show without the hidden infinite scroll trying to load more items every time you scroll.

Rocky Sims
  • 2,316
  • 1
  • 10
  • 13