$ionicScrollDelegate on view load event

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?

1 Like

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.

1 Like

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);
})

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)
2 Likes

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