I was wondering how to integrate custom buttons (side menu, etc) in the nav-bar used for the Nav Router Controller.
I really like the Nav Router because it auto updates the title. But when using a regular header I haven’t found a solution so far of displaying a dynamic title based on different controllers outside the logic of the Nav Router.
So what has to be done to have the nav-bar used for the Nav Router display a back button left and side menu button right.
I did a test with the header-bar element and was able to modify headerTitle attribute from within different controllers by accessing the property from the $rootScope present in AngularJS. (Now I’m not dependable of the nav-bar element and I can keep my logic.)
$rootScope.headerTitle = 'My Title';
To do so, I added $rootScope as a param to my controller function.
This way it’s also possible to access other properties such as leftButtons, rightButtons and modify them per controller basis.
The downside is that when you’ve set a property in controller X and you move to controller Y you’ll have to set the property to null if you don’t want to show it (does not happen in all cases, not sure why this happens).
Now, to add the button for the side menu (right) I wrote this:
@samsinite - are you trying to use multiple nav-bars in your app? Right now we only support one, though this question was brought up yesterday and we aren’t sure what we should do in this situation.
@max, MrJean solution doesnt work for me, I can use header-bar and I see the buttons but I have to change the title in every controller and I loose the transition effect, if I use nav-bar the buttons doesnt appear at all, why nav-bar is not documented?
It is correct that you loose the transition effect. But it’s possible to add it to your main container (pane element, etc) by assigning the associated classes.
But you’re right the documentation should be expanded in order to be clear for the users of Ionic.
Anyway, I think it’s good that we are currently experimenting with possible solutions for a problem. This can only improve the framework over time.
I’ll try the header-bar when I find some spare time and see how that works out
Would it be possible to share some documentation about the possible transitions and how to manually apply them? Just by using CSS or also using the animation attribute?
@daver182 and @MrJean, you are both right we need to document this better. Let me see about getting something better up on the docs this week and get back to you guys on this.
Does that mean that by providing another name you override the default binding?
So, what I mean is that header-bar normally listens to $scope.title, where after assigning a new value it looks for $scope.headerTitle?