After closing keyboard scroll to the top of ion-content?


#1

How to achieve this when i close the keyboard to scroll to top of ion–content?


#2

I have found this but indent preformatted text by 4 spaces`how to specyfi witch ion-contet to got to top if i got nested views?

      $cordovaKeyboard.automaticScrollToTopOnHiding = true;

#3

You can listen to “native.keyboardhide” and then “$ionicScrollDelegate.scrollTop();”

Check this:
http://ionicframework.com/docs/api/service/$ionicScrollDelegate/
and this


#4

@soutlink could you tell me how to listen this native.keyboardhide?


#5

Something like

$window.addEventListener('native.keyboardhide', function(event) {});

Im not sure, but I think you will have to use $scope.$apply, but not really sure about this


#6

do i need to add $window here?
function($scope,$state, $ionicPopup, $timeout,$cordovaKeyboard,$ionicPlatform){


#7

What I would do would be:

myApp.run(function($window, $rootScope) {
    $window.addEventListener('native.keyboardshow', function(event) {
        $rootScope.$broadcast('native.keyboardshow', event);
    });
});

myApp.controller('myController', function($scope){
    $scope.$on('native.keyboardhide', function(angularEvent, keyboardEvent) {
        //Do something here
        console.log(angularEvent, keyboardEvent);
    });
});

Hope this help you


#8
myApp.controller('myController', function($scope){
    $scope.$on('native.keyboardhide', function(angularEvent, keyboardEvent) {
        //Do something here
        console.log(angularEvent, keyboardEvent);
    });
});

I think you mean keyboardshow not listening keyboardhide:

$scope.$on('native.keyboardshow', function(angularEvent, keyboardEvent) {
        //Do something here
        console.log(angularEvent, keyboardEvent);
});