Created
April 20, 2015 22:13
-
-
Save ashconnell/f7e0d9b91b685df5fc0d to your computer and use it in GitHub Desktop.
Ionic: manipulate history stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This example shows how to control the history stack. | |
* Say if we went A->B->C and then when pressing back, you want it to go to A (skip B) | |
*/ | |
// Reference current history set | |
var viewHistory = $ionicHistory.viewHistory(); | |
var history = viewHistory.histories[viewHistory.currentView.historyId]; | |
// Remove both B and C | |
history.stack.splice(1, 2); | |
// Set the cursor and backview to A+1 (where we are now) | |
history.cursor = 1; | |
viewHistory.backView = history.stack[0]; | |
// Trigger back using $ionicHistory. Never use window.history.back() etc | |
$ionicHistory.goBack(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment