0

Scenario: Index Resources > New Resource Form > Resource Detail

Expectations: When I go from Index Resources to New Resource Form, the back button should go back to Index resources. When I submit the New Resource Form, I should be taken to view the Resource Detail, the back button should go back to Index resources.

Actual Result: When I hit the back button from Resource Detail, after the form has been submitted, it would take me back to the New Todo Form.

This is a copy of How to manipulate a back button pointer to point to a previous-previous View, but it proposes a solution using $ionicViewService, but it has been deprecated for $ionicHistory.

How to do it using $ionicHistory?

Mathius17
  • 2,412
  • 2
  • 21
  • 33

1 Answers1

1

You need to override the back button in the 3rd page's controller and then use $ionicHistory.goBack() to navigate back 2 views down the stack.

// override default behaviour
$rootScope.$ionicGoBack = function() {
    // Default -1, -2 goes back 2 views
    $ionicHistory.goBack(-2); 
};

Of course make sure that $ionicHistory and $rootScope are injected into the controller.

Resources:

Cyril Gandon
  • 16,830
  • 14
  • 78
  • 122
theblindprophet
  • 7,767
  • 5
  • 37
  • 55