Search code examples
javascriptangularjsangularjs-ng-repeatanchor-scroll

How to use anchorScroll() with in ng-repeat to have start view at index x


I am trying to list all minutes in 24 hours duration with a step of 15 minutes.
So, I have these minutes lists in array and looping them using ng-repeat.
In my case, when page is loaded I would like to show list from 07:30 as top, but if I scroll up it must be able to show 07:15, 07:00...

I tried to use filter: 'after', it shows from 07:30 but not before 07:15, 07:00...

Is there a way the ng-repeat starts showing from element 07:30?

I have created a plunker with what I have tried.

Any help please, thanks in advance.


Solution

  • Here is the working plunker

      $scope.goto = function (){
        $timeout(function() {
                $location.hash(30);
                $anchorScroll();
            });
      }
    

    Use $timeout :-)