How to not allow Backbutton using Ionic when there is a condition?

Asked

Viewed 35 times

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 doesn’t work. Any suggestions?

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);
      }
    })
  • It worked, thanks @el Corleone.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.