angularjs - Hide nav-button depending on the current state change -


how can hide/show button based on 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> 

if have parent controller containing views can 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 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> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -