How not to allow the BackButton using Ionic, when there is a condition?

0

How can I hide (and / or change the direction of the BackButton) when I have a condition in the View?

I'm trying this way:

if (window.localStorage.getItem("fonecedor_carrinho") != '0' && window.localStorage.getItem("fonecedor_carrinho") != null){
    $scope.hideBackButton = false;
}else{
    $scope.hideBackButton = true;
}

But it does not work. Any suggestions?

    
asked by anonymous 07.04.2017 / 15:56

1 answer

1

This is possibly the simplest solution.

.controller('seuCtrl', function($ionicNavBarDelegate) {
      if (window.localStorage.getItem("fonecedor_carrinho") != '0' && window.localStorage.getItem("fonecedor_carrinho") != null){
          $ionicNavBarDelegate.showBackButton(false);
      }else{
          $ionicNavBarDelegate.showBackButton(true);
      }
    })
    
07.04.2017 / 16:42