diff --git a/js/ext/angular/src/directive/ionicNavBar.js b/js/ext/angular/src/directive/ionicNavBar.js index 0a0b30a1f5..1fbb9a125e 100644 --- a/js/ext/angular/src/directive/ionicNavBar.js +++ b/js/ext/angular/src/directive/ionicNavBar.js @@ -144,6 +144,7 @@ function($scope, $element, $attrs, $ionicViewService, $animate, $compile, $ionic this.showBar = function(show) { $scope.isInvisible = !show; + $scope.$parent.$hasHeader = !!show; }; this.setTitle = function(title) { @@ -290,7 +291,6 @@ function($ionicViewService, $rootScope, $animate, $compile) { $scope.shouldAnimate = true; $scope.isReverse = false; $scope.isInvisible = true; - $scope.$parent.$hasHeader = true; $scope.$on('$destroy', function() { $scope.$parent.$hasHeader = false; diff --git a/js/ext/angular/test/directive/ionicNavBar.unit.js b/js/ext/angular/test/directive/ionicNavBar.unit.js index fd46841876..42dea178d7 100644 --- a/js/ext/angular/test/directive/ionicNavBar.unit.js +++ b/js/ext/angular/test/directive/ionicNavBar.unit.js @@ -74,7 +74,7 @@ describe('ionNavBar', function() { expect($scope.backButtonShown).toBe(false); }); - it('should showBar', function() { + it('showBar should set isInvisible', function() { var ctrl = setup(); expect($scope.isInvisible).toBeUndefined(); ctrl.showBar(true); @@ -83,6 +83,15 @@ describe('ionNavBar', function() { expect($scope.isInvisible).toBe(true); }); + it('showBar should set $parent.$hasHeader', function() { + var ctrl = setup(); + expect($scope.$parent.$hasHeader).toBeUndefined(); + ctrl.showBar(true); + expect($scope.$parent.$hasHeader).toBe(true); + ctrl.showBar(false); + expect($scope.$parent.$hasHeader).toBe(false); + }); + it('should setTitle', function() { var ctrl = setup(); expect($scope.title).toBeFalsy(); @@ -230,10 +239,10 @@ describe('ionNavBar', function() { expect(el.children().eq(0).html()).toBe('super content 4'); }); - it('should $parent.$hasHeader and unset on $destroy', function() { + it('should set $parent.$hasHeader to false on $scope.$destroy', function() { var el = setup(); var parentScope = el.scope().$parent; - expect(parentScope.$hasHeader).toBe(true); + parentScope.$hasHeader = true; el.scope().$destroy(); expect(parentScope.$hasHeader).toBe(false); }); @@ -255,6 +264,7 @@ describe('ionNavBar', function() { it('should have invisible class (default true)', function() { var el = setup(); + el.scope().$apply(); expect(el.hasClass('invisible')).toBe(true); el.scope().$apply('isInvisible = false'); expect(el.hasClass('invisible')).toBe(false);