Ionic history stack on iOS - SOLVED


#1

I have created this app to run on iOS

In safari and chrome this code pen runs correctly. In my app on an iOS device if you follow these steps it resets the history for the application.

Home > Status > Status 3 switch to Lookup > Product Details > Recommendations
This works fine, but when you go back to Home and then try to go back to Lookup the app navigates to ‘tab.home’ and not lookup. This clears the history on the home tab. When you navigate to Lookup from there it takes you to the page it was at, but trying to navigate on the Lookup tab will reset the history of that tab as well.

As I said up front this only presents itself on iOS devices both an iPad and iPod. Is there some limitation on history when running on a device?


#2

After trying to remove and change things incrementally I removed the controller and everything worked. I believe I was doing something strange with $rootscope. Once I removed the code regarding $rootscope everything works as intended.

angular.module('pos.controllers', [])
.controller('RouteCtrl', function($scope, $state, $rootScope) {

  $rootScope.$$listeners.$stateChangeStart = [];

  $scope.statename = $state.$current.name;
  $scope.urlname = $state.href($state.$current.name);

  $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
    window.alert("GOING FROM '" + fromState.name + "' with url '" + $state.href(fromState.name) + "' TO '" + toState.name + "' with url '" + $state.href(toState.name) + "'");
  })

  $rootScope.$on('$stateNotFound', function(event, unfoundState, fromState, fromParams) {
    window.alert(unfoundState.to + " state not found");
  })
})