Nav-clear equivalent in controller

Hi, I’m an Ionic/Angular newbie at this point, apologies if this is an obvious answer.

I have the following code in my side menu controller which loads an action sheet when one of the menu buttons is clicked:

.controller('MenuCtrl', function($scope, $location, $ionicActionSheet, $ionicSideMenuDelegate) {
  $scope.showActions = function() {

    $ionicActionSheet.show({
      buttons: [
        { text: 'Contact Support' },
        { text: 'Account Settings' },
        { text: 'App Settings' },
      ],
      cancelText: 'Cancel',
      buttonClicked: function(index) {
        $ionicSideMenuDelegate.toggleRight(); // Close the menu
        if (index == 0) {
          $location.path("/app/support");
        } else if (index == 1) {
          $location.path("/app/settings/account");
        } else if (index == 2) {
          $location.path("/app/settings/app")
        }
        return true;
      }
    });
  };
})

As you see, I already figured out how to do the equivalent of menu-close by using $ionicSideMenuDelegate. But how can I do the equivalent of nav-clear in the controller? In other words, when $location.path() is called, rather than pushing onto the nav stack, I just want to load the view and reset the stack. I looked at the $ionicNavBarDelegate but it didn’t appear to have any clear method.

Thanks in advance for any help!

Solved my problem. I looked at the implementation of nav-clear and found what I needed:

$ionicViewService.nextViewOptions({
  disableAnimate: true,
  disableBack: true
});

Cheers, really enjoying Ionic so far.

2 Likes

Awesome, glad to see you got this.

Just for reference, in case anyone else needs this, you can check out the js for any of our directives here.

https://github.com/driftyco/ionic/tree/master/js/angular/directive