KickerKeeper KickerKeeper - 1 year ago 192
AngularJS Question

Dynamically add buttons in Ionic to Nav-bar

I have a nav bar and I want to add a save button to the nav bar for only one screen. I was reading the blogs and everyone was saying how you declare your buttons in the view and don't access them in a controller. That is all well and good but I have to imagine people still want to hide and show nav buttons. Am I missing something?

<body ng-app="App">
<!-- The nav bar that will be updated as we navigate -->
<ion-nav-bar class="bar-positive">
<ion-nav-back-button> </ion-nav-back-button>
<ion-nav-buttons side="right">
<button id="saveButton" class="button button-clear">Save</button>


Answer Source

You can add buttons on left or right side in navigation bar from any screen containing <ion-view>.Like

<ion-view title="New Screen">
    <ion-nav-buttons side="primary">
        <button class="button" ng-click="doSomething()">
            New Button

So this "New Button" will only come for "New Screen".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download