Custom Back-Button and IonicLoading wont play nice


#1

I am using the following code to overwrite default behavior of the back button so I can control pages that I don’t want to be added to history.

$rootScope.goBack = function(evt) {
    evt.preventDefault();
    evt.stopPropagation();
    window.history.back();
};

Although this works fine the moment I show a message with Ionic Loading the back button stops working.

$ionicLoading.show({
      template: $scope.followed?'Following':'Unfollowed',
      noBackdrop : true,
      duration: 1000
})

Anyone knows why ionicLoading interferes with the history state and how I can prevent this?


#2

I still dont know what is causing this but I found a way to bypass it.

It seems that the problem is caused when defining a duration period to auto-remove the loading dialogue. When explicitly calling $ionicLoading.hide(); then the problem goes away.

Here is the actual working code:

      $ionicLoading.show({
            template: $scope.followed?'Following':'Unfollowed',
            noBackdrop : true,
        })

        $timeout(function(){$ionicLoading.hide();},1000);