1

In a tab based ionic 1.x app, I'd like to display a customized "goBackHome" button only when the <ion-nav-back-button> is not displayed.

How to detect is the <ion-nav-back-button> is displayed or not?

g000
  • 11
  • 4

2 Answers2

0

Here is the solution from here:

$rootScope.$on('$viewHistory.historyChange', function(e, data) {
        $scope.isBackButtonShown = !!data.showBack;
    });

Additionally, it might help:

App.js - custom text and icon. You can use $ionicConfigProvider.

.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {

  $ionicConfigProvider.backButton.previousTitleText(false).text('customText'); 
  $ionicConfigProvider.backButton.icon('ion-ios-home');
})

Controller.js - force Ionic to display back button on certain page

.controller('yourCtrl', function($scope) {

$scope.$on('$ionicView.beforeEnter', function (event, viewData) {
  viewData.enableBack = true;
}); 

})

Additionally resources:

Community
  • 1
  • 1
Tomislav Stankovic
  • 3,080
  • 17
  • 35
  • 42
  • $viewHistory.historyChange seems to be undefined and your reference to ionic forum points to an old version of navBackButton.js . Nevertheless successive comments in ionic forum suggest an alternative (and working solution). – g000 Jun 27 '16 at 19:27
0

A working solution for the current Ionic release:

$rootScope.$on('$ionicView.beforeEnter', function(e, data) { $scope.isBackButtonShown = data.enableBack; });

g000
  • 11
  • 4