I am developing an android app using Ionic Framework.
In that, I have three views, view1, view2 and view3
.
Navigation will be like view1 -> view2 -> view3
When moving back to view2
from view3
, I need to change a stateParam param1
value of view2
to perform some operations. Below code shows you that I am changing the stateParam value of view2
when clicking back button in view3
Following is the code to override the action of android device backbutton
$ionicPlatform.registerBackButtonAction(function() {
if ($state.current.name == "view3") {
$ionicHistory.backView().stateParams = {param1:true};
$ionicHistory.goBack(); // moves to view2
} else {
$ionicHistory.goBack();
}
}, 100);
After moving back to view2
, If I click back button now, it is moving to view3
and not to view1
. Now I am able to view only view3
and view2
by clicking back button, Not at all moving to view1
.
How to make back button to move to view1
from view2
Even after changing the stateParam value of view2
?