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?
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?
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:
A working solution for the current Ionic release:
$rootScope.$on('$ionicView.beforeEnter', function(e, data) {
$scope.isBackButtonShown = data.enableBack;
});