Navigate and clearHistory

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();   };

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});

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});
  };

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

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:

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

Wow, Thanks for the help :smile: