Skip to content

Commit 2d39418

Browse files
author
Adam Bradley
committed
fix(backButton): Do not show back button if no attributes set, closes #549
1 parent 2ac71aa commit 2d39418

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

js/ext/angular/src/directive/ionicViewState.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
9595
if(tAttrs.type) tElement.addClass(tAttrs.type);
9696

9797
return function link($scope, $element, $attr) {
98-
$scope.enableBackButton = true;
98+
var canHaveBackButton = !(!tAttrs.backButtonType && !tAttrs.backButtonLabel);
99+
$scope.enableBackButton = canHaveBackButton;
99100

100101
$rootScope.$on('viewState.showNavBar', function(e, showNavBar) {
101102
if(showNavBar === false) {
@@ -121,7 +122,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
121122
$scope.rightButtons = data.rightButtons;
122123

123124
if(typeof data.hideBackButton !== 'undefined') {
124-
$scope.enableBackButton = data.hideBackButton !== true;
125+
$scope.enableBackButton = data.hideBackButton !== true && canHaveBackButton;
125126
}
126127

127128
if(data.animate !== false && $attr.animation && data.title && data.navDirection) {

js/ext/angular/test/directive/ionicView.unit.js

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ describe('Ionic View', function() {
8383
expect(element.hasClass('bar-positive')).toEqual(true);
8484
});
8585

86+
it('should not show the back button if no back button attributes set', function() {
87+
var element = compile('<nav-bar></nav-bar>')(scope);
88+
scope.$digest();
89+
var backButton = element.find('div').find('button');
90+
expect(backButton.length).toEqual(0);
91+
});
92+
8693
it('should set just a back button icon, no text', function() {
8794
var element = compile('<nav-bar back-button-icon="ion-back" back-button-type="button-icon"></nav-bar>')(scope);
8895
scope.$digest();

0 commit comments

Comments
 (0)