Is it not possible to create right button when using nav-bar directive


#1

Hello Is it not possible to use right button when using nav-bar directive in ionic? I saw the nav-bar directive and it’s template seems like doesnot support right button?


#2

I just created an issue: https://github.com/driftyco/ionic/issues/254


#3

Okay, just fixed this issue. The way you can do this is to specify the scope variables for the rightButtons on your <nav-page>:

    <pane nav-router animation="slide-left-right">
      <nav-bar animation="nav-title-slide-ios7" type="bar-positive" back-button-type="button-icon" back-button-icon="icon ion-arrow-left-c"></nav-bar>
      <ng-view></ng-view>
    </pane>

    <script id="page1.html" type="text/ng-template">
      <nav-page title="'Bears'" right-buttons="rightButtons">
      </nav-page>
    </script>

And if you have a controller for that page set up in the router:

      .controller('MyCtrl', function($scope) {
        $scope.rightButtons = [
          { 
            content: 'Hello',
            tap: function(e) {
              console.log('Click button');
            }
          }
        ]
      });


#4

Hi I might just be stupid, but when the button is clicked how do you actually redirect to the desired next page? (on ‘tap: function(){}’)


#5

Like this :

tap : function() {
    $state.go('name-of-your-state-here');
}