# Clear History on View Navigation

**URL:** <https://forum.ionicframework.com/t/clear-history-on-view-navigation/16397>\
**Category:** ionic-v1\
**Created:** [January 26, 2015, 7:13pm UTC](https://forum.ionicframework.com/t/clear-history-on-view-navigation/16397 "2015-01-26T19:13:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dalefrancis88](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dalefrancis88/32/76226_2.png) [@dalefrancis88](https://forum.ionicframework.com/u/dalefrancis88)\
**Post date:** [January 26, 2015, 7:13pm UTC](https://forum.ionicframework.com/t/clear-history-on-view-navigation/16397/1 "2015-01-26T19:13:03Z")

</div>

Hey,

I have a flow in my app where users are signing up. What i want to do it make it so that once they have hit the final “done” button and the account created, the history is cleared/reset.

Currently i am running this flow by changing state.

In my searching I have found “$ionicViewService.clearHistory();” this seems to work however it seems to be too late when i try it and there is still a back button.

I then tried the events below. These seemed to work as well but again too late. The view shows the back button but it doesnt go anywhere. What do i do to “refresh” or start another user flow. I feel this has got to be simple so I know i must be missing something.

```
    $scope.$on('$ionicView.leave', function () {
    $ionicViewService.clearHistory();
});
$scope.$on('$ionicView.beforeLeave', function () {
    $ionicViewService.clearHistory();
});
$scope.$on('$ionicView.afterLeave', function () {
    $ionicViewService.clearHistory();
});
$scope.$on('$ionicView.enter', function () {
    $ionicViewService.clearHistory();
});

```

Any help or advice would be greatly appreciated.

Dale

---

<div class="post-metadata">

**Author:** ![brandyshea](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/brandyshea/32/148286_2.png) [@brandyshea](https://forum.ionicframework.com/u/brandyshea)\
**Post date:** [January 26, 2015, 9:45pm UTC](https://forum.ionicframework.com/t/clear-history-on-view-navigation/16397/2 "2015-01-26T21:45:04Z")

</div>

I may be misunderstanding you, but this will reset the history stack so the next view is the root of the stack:

```
$ionicHistory.nextViewOptions({
     historyRoot: true
});

```

I call it before navigating to my home page.

---

<div class="post-metadata">

**Author:** ![dalefrancis88](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dalefrancis88/32/76226_2.png) [@dalefrancis88](https://forum.ionicframework.com/u/dalefrancis88)\
**Post date:** [January 26, 2015, 9:51pm UTC](https://forum.ionicframework.com/t/clear-history-on-view-navigation/16397/3 "2015-01-26T21:51:56Z")

</div>

> [@brandyshea](#):
>
> $ionicHistory.nextViewOptions({  
> historyRoot: true  
> });

Hahaha i **knew** it’d be simple. Thanks for that. It’s always fun/hard looking for those simple/easy snippets. Will put that one in my back pocket 😄
