How can I customize the nav bar depending on state?


#1

Hi, i’ve looked around but can’t find the answer to what I thought would be a newbie question.

Am I right in thinking, that if done properly you should only need to declare the nav bar once? However, how can I then customize the contents of it depending on which state I’m in? I considered looking into the ng-hide or ng-show directives, but then i would need code in each of my controllers to indicate whether or not a given item (button) should be visible in when in a given state, and the nav bar could potentially have a lot of markup to account for all possible states. Below is the code for my nav bar, what is the correct way to control the appearance of it’s contents depending on the state of the application? (I am using ui.router) So in this simple example below, I want to hide the sign in button once you are signed in.

<ion-nav-buttons side="right">
	<button class="button" ng-click="gotoSignIn()">Sign In</button>
</ion-nav-buttons>

many thanks


#2

Buttons can be added dynamically by adding them to a view.

http://ionicframework.com/docs/api/directive/ionNavButtons/


#3

Awesome, had spotted those docs but I thought they could only be added directly in the ion-nav-bar, spot on, thanks alot!