Skip to content

Commit

Permalink
fix(ionView): initialize hideBack/hideNav to false if undefined
Browse files Browse the repository at this point in the history
Addresses comments in #1157
  • Loading branch information
ajoslin committed Apr 29, 2014
1 parent d1896e9 commit 5e56c2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
26 changes: 14 additions & 12 deletions js/angular/directive/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,21 @@ IonicModule

}

if (angular.isDefined($attr.hideBackButton)) {
$scope.$watch($attr.hideBackButton, function(value) {
// Should we hide a back button when this tab is shown
navBarCtrl.showBackButton(!value);
});
}
var hideBackAttr = angular.isDefined($attr.hideBackButton) ?
$attr.hideBackButton :
'false';
$scope.$watch(hideBackAttr, function(value) {
// Should we hide a back button when this tab is shown
navBarCtrl.showBackButton(!value);
});

if (angular.isDefined($attr.hideNavBar)) {
$scope.$watch($attr.hideNavBar, function(value) {
// Should the nav bar be hidden for this view or not?
navBarCtrl.showBar(!value);
});
}
var hideNavAttr = angular.isDefined($attr.hideNavBar) ?
$attr.hideNavBar :
'false';
$scope.$watch(hideNavAttr, function(value) {
// Should the nav bar be hidden for this view or not?
navBarCtrl.showBar(!value);
});

};
}
Expand Down
10 changes: 10 additions & 0 deletions test/unit/angular/directive/view.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ describe('ionView directive', function() {
expect(el.controller('ionNavBar').showBackButton).toHaveBeenCalledWith(true);
});

it('should show back button by default', function() {
var el = setup();
expect(el.controller('ionNavBar').showBackButton).toHaveBeenCalledWith(true);
});

it('should showBar depending on what is given', function() {
var el = setup('hide-nav-bar="shouldHide"');
expect(el.controller('ionNavBar').showBar).toHaveBeenCalledWith(true);
Expand All @@ -66,6 +71,11 @@ describe('ionView directive', function() {
expect(el.controller('ionNavBar').showBar).toHaveBeenCalledWith(true);
});

it('should showBar by default', function() {
var el = setup();
expect(el.controller('ionNavBar').showBar).toHaveBeenCalledWith(true);
});

it('should setTitle on change, but not with initial value', function() {
var el = setup('title="{{something}}-1"');
//Should not setTitle with initial value
Expand Down

0 comments on commit 5e56c2d

Please sign in to comment.