Controller called twice for custom directive inside ion-nav-buttons

I build my own directive rs-notification to handle upcoming MQTT messages and provide visual feedback.

I put this directive inside the ion-nav-buttons component:

        <ion-nav-bar class="rs-header">
            <ion-nav-buttons side="left">
                <button class="button button-icon button-clear ion-navicon color-primary-light" menu-toggle="left"></button>
            <ion-nav-buttons side="right">
        <ion-nav-view name="menuContent"></ion-nav-view>

In that case the controller of rs-notification is called twice, if I put the directive in an higher level that won’t happen.
Am I doing something wrong?

(More details at


I looked at Your stackoverflow question - I don’t understand why You wrote the controller the way You did. Also: are You sure as far as the logic of Your application goes that You need to use a controller? You count badges in the controller, You might as well do that inside the directive.

Hi psyche,

I’don’t understand what’s wrong in my controller, can You be more specific?

Why did You write it as a variable and not



But honestly I don’t think this is the problem… I was just curious :smile:
Did You try using the


function in the directive?

Thanks for the advice, I didn’t know the link function in directive, I will take a look at that.

Anyway I’d like to know if that problem it’s for something I got wrong or can be a ionic issue.

Go to the angular docs: and scroll to:
Creating a Directive that Adds Event Listeners

I hope that helps