Skip to content

Commit

Permalink
fix(backButton): Do not show back button if no attributes set, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Bradley committed Feb 7, 2014
1 parent 2ac71aa commit 2d39418
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/ext/angular/src/directive/ionicViewState.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
if(tAttrs.type) tElement.addClass(tAttrs.type);

return function link($scope, $element, $attr) {
$scope.enableBackButton = true;
var canHaveBackButton = !(!tAttrs.backButtonType && !tAttrs.backButtonLabel);
$scope.enableBackButton = canHaveBackButton;

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

if(typeof data.hideBackButton !== 'undefined') {
$scope.enableBackButton = data.hideBackButton !== true;
$scope.enableBackButton = data.hideBackButton !== true && canHaveBackButton;
}

if(data.animate !== false && $attr.animation && data.title && data.navDirection) {
Expand Down
7 changes: 7 additions & 0 deletions js/ext/angular/test/directive/ionicView.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ describe('Ionic View', function() {
expect(element.hasClass('bar-positive')).toEqual(true);
});

it('should not show the back button if no back button attributes set', function() {
var element = compile('<nav-bar></nav-bar>')(scope);
scope.$digest();
var backButton = element.find('div').find('button');
expect(backButton.length).toEqual(0);
});

it('should set just a back button icon, no text', function() {
var element = compile('<nav-bar back-button-icon="ion-back" back-button-type="button-icon"></nav-bar>')(scope);
scope.$digest();
Expand Down

0 comments on commit 2d39418

Please sign in to comment.