Ki1L3r
September 18, 2015, 7:19am
1
Good Morning guys,
I have a question, I have the main bar created like this:
<ion-nav-bar ng-controller="AppCtrl">
<ion-nav-back-button>
{{'back_button'| translate}}
</ion-nav-back-button>
<ion-nav-title ng-click="mainRouter()">
<div class="page-title">{{title}}</div>
<div class="page-sub-title">{{date}}</div>
</ion-nav-title>
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button ui-sref="app.settings" class="button icon ion-ios-information-outline"></button>
</button>
</ion-nav-buttons>
</ion-nav-bar>
The cuestion is… when I go to another view that has for example another right button it overwrites it, its possible to maintain the two buttons?
<ion-view>
<ion-nav-buttons side="right" >
<button class="button ion-plus" ui-sref='app.new'> </button>
</ion-nav-buttons>
....
lmenus
September 18, 2015, 7:56am
2
Can’t you do this in the other view?
<ion-view>
<ion-nav-buttons side="right">
<button class="button ion-plus" ui-sref='app.new'>
</button>
<button ui-sref="app.settings" class="button icon ion-ios-information-outline">
</button>
</ion-nav-buttons>
</ion-view>
Ki1L3r
September 18, 2015, 10:54am
3
no because the plus button is specific in that view and only appears there.
lmenus
September 18, 2015, 2:20pm
4
I think either I misunderstood you or you misunderstood me. By including those two buttons ONLY in the specific view as you wanted they won’t appear anywhere else. Alternatively, you can apply ng-hide/ng-show on a button if the user is in the specific view.
Ki1L3r
September 21, 2015, 2:51pm
5
how do you say not no show in a specific view?
lmenus
September 22, 2015, 5:28pm
6
Are you using ui-router?
If yes, it is pretty simple. You can get the url of a view with $state.$current.name and then you can apply it in your template with attribute ng-hide="hideInView()"
and define the function in your controller as
$sccope.hideInView = function() {
if ($state.$current.name === "your.state") return true; else return false;
}
lmenus
September 23, 2015, 1:55pm
8
I actually have a typo there, should be $state.$current.name ! Updating it now sorry
lmenus
September 23, 2015, 2:02pm
9
I stay corrected. You can use either of those. Here’s a little discussion on that if you’re interested https://github.com/angular-ui/ui-router/issues/176