Skip to content

Commit

Permalink
feat($ionicNavBarDelegate): showBackButton returns whether bar is shown
Browse files Browse the repository at this point in the history
Closes #1076

If the user for example switches tabs,
$ionicNavBarDelegate.getPreviousTitle() will return the title from the
navbar within the previous tab.  In this case, the back button will not
be shown.  To not use the previous title in a case like this, you can
now do:

```js
var shouldShowTitle = $ionicNavBarDelegate.showBackButton();
if (shouldShowTitle) {
  $scope.previousTitle = $ionicNavBarDelegate.getPreviousTitle();
}
```
  • Loading branch information
ajoslin committed Apr 8, 2014
1 parent 24a415c commit 933a555
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions js/ext/angular/src/directive/ionicNavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ angular.module('ionic.ui.navBar', ['ionic.service.view', 'ngSanitize'])
* @ngdoc method
* @name $ionicNavBarDelegate#showBackButton
* @description
* Set whether the {@link ionic.directive:ionNavBackButton} should be shown
* Set/get whether the {@link ionic.directive:ionNavBackButton} is shown
* (if it exists).
* @param {boolean} show Whether to show the back button.
* @param {boolean=} show Whether to show the back button.
* @returns {boolean} Whether the back button is shown.
*/
'showBackButton',
/**
Expand Down Expand Up @@ -140,7 +141,10 @@ function($scope, $element, $attrs, $ionicViewService, $animate, $compile, $ionic
};

this.showBackButton = function(show) {
$scope.backButtonShown = !!show;
if (arguments.length) {
$scope.backButtonShown = !!show;
}
return !!($scope.hasBackButton && $scope.backButtonShown);
};

this.showBar = function(show) {
Expand Down

0 comments on commit 933a555

Please sign in to comment.