mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(backButton): Do not show back button if no attributes set, closes #549
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user