mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
show/hide back button from view
This commit is contained in:
23
js/ext/angular/src/directive/ionicViewState.js
vendored
23
js/ext/angular/src/directive/ionicViewState.js
vendored
@@ -174,15 +174,12 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
return function link($scope, $element, $attr) {
|
||||
// Should we hide a back button when this tab is shown
|
||||
$scope.hideBackButton = $scope.$eval($scope.hideBackButton);
|
||||
if($scope.hideBackButton) {
|
||||
$rootScope.$broadcast('viewState.showBackButton', false);
|
||||
}
|
||||
|
||||
$scope.hideNavBar = $scope.$eval($scope.hideNavBar);
|
||||
|
||||
if($scope.hideBackButton === true) {
|
||||
$scope.$emit('viewState.hideBackButton');
|
||||
} else {
|
||||
$scope.$emit('viewState.showBackButton');
|
||||
}
|
||||
|
||||
// watch for changes in the left buttons
|
||||
$scope.$watch('leftButtons', function(value) {
|
||||
$scope.$emit('viewState.leftButtonsChanged', $scope.leftButtons);
|
||||
@@ -212,14 +209,22 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
tElement.addClass('hide');
|
||||
|
||||
return function link($scope, $element) {
|
||||
$element.bind('click', goBack);
|
||||
$element.bind('tap', goBack);
|
||||
|
||||
$rootScope.$on('$viewHistory.historyChange', function(e, data) {
|
||||
if(data.showBack) {
|
||||
$scope.showButton = function(val) {
|
||||
if(val) {
|
||||
$element[0].classList.remove('hide');
|
||||
} else {
|
||||
$element[0].classList.add('hide');
|
||||
}
|
||||
};
|
||||
|
||||
$rootScope.$on('$viewHistory.historyChange', function(e, data) {
|
||||
$scope.showButton(data.showBack);
|
||||
});
|
||||
|
||||
$rootScope.$on('viewState.showBackButton', function(e, data) {
|
||||
$scope.showButton(data);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user