Controller inside ion-nav-buttons fired twice

I need a controller inside the ion-nav-buttons to display badges based on need. But the controller inside the ion-nav-buttons is fired twice, whereas it works smoothly if I put it outside the ion-nav-buttons.

Example: Ionic Playground Link

HTML content

<body ng-app="app">
    <ion-side-menus>
        <ion-side-menu-content>
            <ion-nav-bar class="bar bg-main">
            <ion-nav-back-button style="color: #fff">
                </ion-nav-back-button>
                <ion-nav-back-button style="color: #fff">
                </ion-nav-back-button>
                <ion-nav-buttons side="right">
                    <a ng-href="#/notification" class="button" ng-controller="NotifyCtrl">
                    </a>
                </ion-nav-buttons>
            </ion-nav-bar>
            <ion-nav-view name="" animation="slide-left-right"></ion-nav-view>
        </ion-side-menu-content>
        
    </ion-side-menus>
</body>

Code

angular.module('app', ['ionic']).
controller('NotifyCtrl', ['$scope', function($scope){
  alert();
}]);

Hello,

Why don’t you put it in your ion-nav-buttons tag ?

I did not get the scope when I put controller in ion-nav-buttons. Moreover what if I need multiple controller inside the ion-nav-buttons?

What’s your purpose ?

Think that you can put a ion-nav-buttons tag in your ion-view. This way you can use the controller of your view.

<ion-view>
    <ion-nav-buttons side="right">
        <button id="rightButton">{{value}}</button>
    </ion-nav-buttons>
    <ion-content>
          <--------->
    </ion-content>
</ion-view>

The application has multiple views working through routers. The top bar is in the main page and its common for all the other views, every view has its own controller. The ion-nav-buttons contains the notification icon and I will update the notifications if any based on interval using the Notify controller.

Ok, I understand.

So your main view is an abstract one, I can think that you have a controller for it.
Why don’t you put the code you want for your NotifyCtrl in the main controller ?

Hey thanks for quick replies.

The main view does not have a controller, it just contains a router which redirects to other templates. This main view also contains the nav buttons etc.

Hey, how did you resolve the issue?