@@ -601,6 +601,37 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
601601 viewHistory . backView && viewHistory . backView . go ( ) ;
602602 } ,
603603
604+ /**
605+ * @ngdoc method
606+ * @name $ionicHistory#removeBackView
607+ * @description Remove the previous view from the history completely, including the
608+ * cached element and scope (if they exist).
609+ */
610+ removeBackView : function ( ) {
611+ var self = this ;
612+ var currentHistory = viewHistory . histories [ this . currentHistoryId ( ) ] ;
613+ var currentCursor = currentHistory . cursor ;
614+
615+ var currentView = currentHistory . stack [ currentCursor ] ;
616+ var backView = currentHistory . stack [ currentCursor - 1 ] ;
617+ var replacementView = currentHistory . stack [ currentCursor - 2 ] ;
618+
619+ // fail if we dont have enough views in the history
620+ if ( ! backView || ! replacementView ) {
621+ return ;
622+ }
623+
624+ // remove the old backView and the cached element/scope
625+ currentHistory . stack . splice ( currentCursor - 1 , 1 ) ;
626+ self . clearCache ( [ backView . viewId ] ) ;
627+ // make the replacementView and currentView point to each other (bypass the old backView)
628+ currentView . backViewId = replacementView . viewId ;
629+ currentView . index = currentView . index - 1 ;
630+ replacementView . forwardViewId = currentView . viewId ;
631+ // update the cursor and set new backView
632+ viewHistory . backView = replacementView ;
633+ currentHistory . currentCursor += - 1 ;
634+ } ,
604635
605636 enabledBack : function ( view ) {
606637 var backView = getBackView ( view ) ;
0 commit comments