Navigate and clearHistory


#1

Hi , I’m having a problem with this code , is it possible to navigate and clear the previous history page you came from?

<a ui-sref='tabs.lessonlist2unlock'class="button button-stable" ng-click="clearViewHistories" >

$scope.clearViewHistories = function() {
$ionicViewService.clearHistory();   };

#2

with clearHistory you will remove the entire history
and you need to call the function:

ng-click="clearViewHistories()"

if you want to replace only the last entry you can call
$state.go('statename', params, { replace: true});


#3

Am i going to put this code :

$state.go('statename', params, { replace: true});

Inside the clearViewHistories() ?

$scope.clearViewHistories = function() {
   $state.go('statename', params, { replace: true});
  };

#4

yep and you should replace statename with your state and params with an object with your state parameters or an empty object.


#5

Just Like this ?

$state.go('tabs.myNewHomePage', params, { replace: true});

I’m sorry but I’m not familiar in chaging params with an object , Can you please give me some example in changing the params with an object with my state parameters ? Thanks :smile:


#6
$state.go('tabs.myNewHomePage', {}, {replace: true});

#7

Wow, Thanks for the help :smile: