$ionicScrollDelegate on view load event


#1

I’m building a chat application & I’d like the ion-list to scroll to the last ion-item when the view is loaded. I have attempted using $ionicScrollDelegate.scrollBottom() within my ChatCtrl to no avail.

How would I achieve this otherwise?


#2

Sorry for the “me too”, but I’m experiencing this same issue. I’m interested to know what the ideal solution is. Thanks for posting the question.


#3

Hey I found an easy solution, do the $ionicScrollDelegate.scrollBottom() in a setTimeout or $timeout.

I’m using 10ms and it is working for me on Ripple emulator and my Galaxy S2 on Android 4.4.2 -

.controller('AddComment', function($scope, $state, $ionicScrollDelegate) {
    setTimeout(function() {
        $ionicScrollDelegate.scrollBottom();
    }, 10);
})

#4

I believe the problem is that when the controller has loaded, the child <ion-content> has not loaded yet. Therefore, $ionicScrollDelegate won’t work until a timeout.

Fixes:

  1. Make your ng-controller a sibling of ion-content
  2. Use a timeout (I would recommend inject $timeout service)

Scroll to bottom on state load
#5

With $timeout service, $ionicScrollDelegate doesnt seems to work. I am using latest ionic version 1.3