Hide ion-nav-back-button


#1

I have an app where my first screen is a login, then when the user logs in I redirect my app to another view using $state.go('app.foo');

The problem is that in my ion-nav-bar I see the ion-nav-back-button, but I don’t want it when the user comes from the login.

Any ideas?
Thanks!


#2

can you use the new ‘nav-clear’

http://ionicframework.com/docs/nightly/api/directive/navClear/


#3

I didn’t know about that. But how can I use it with Javascript? I am redirecting to another view using $state.go('app.foo'); only after that redirection I don’t want the back button.


#4

Can you just apply it to whatever button causes that state change?

If not, then here is the navClear directive. Take it’s code and apply in your controller.

.directive('navClear', ['$ionicViewService', function($ionicViewService) {
  return {
    restrict: 'AC',
    link: function($scope, $element, $attr) {
      $element.bind('click', function(){
        $ionicViewService.nextViewOptions({
          disableAnimate: true,
          disableBack: true
        });
      });
    }
  };
}]);


#5

Ok, thanks @darrenahunter and @Calendee

Didn’t know about this nav-clear


#6

FYI : Here is a sample :


#7

Thanks! It really help me.