Reputation: 5167
How can i hide/show this button based on my current view?
<ion-nav-buttons side="right">
<button id="search_button" class="button button-icon ion-ios-search button-clear" ng-click="search()">
</button>
</ion-nav-buttons>
Upvotes: 0
Views: 636
Reputation: 2914
If you have a parent controller containing some views you can do the following :
.controller("parentController", function($scope){
var self = this;
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
self.showButton = (toState.name == "yourStateName");
});
});
HTML :
<div ng-controller="parentController as parentCtrl">
<ui-view> </ui-view>
<ion-nav-buttons side="right">
<button id="search_button" class="button button-icon ion-ios-search button-clear" ng-click="search()" ng-if="parentCtrl.showButton">
</button>
</ion-nav-buttons>
</div>
Upvotes: 1
Reputation: 91
You can probably add a flag to the controller which is responsible for this view and use the ng-if or ng-show/ng-hide directives on the button element. I couldn't give a more detailed answer without more context to the question.
Upvotes: 0