mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicNavBarDelegate): showBackButton returns whether bar is shown
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(); } ```
This commit is contained in:
10
js/ext/angular/src/directive/ionicNavBar.js
vendored
10
js/ext/angular/src/directive/ionicNavBar.js
vendored
@@ -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',
|
||||
/**
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user