fix(backButton): Do not show back button if no attributes set, closes #549

This commit is contained in:
Adam Bradley
2014-02-06 20:31:45 -06:00
parent 2ac71aa8ee
commit 2d39418d0b
2 changed files with 10 additions and 2 deletions

View File

@@ -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) {
@@ -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) {

View File

@@ -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();