Roy
Roy

Reputation: 910

Calling a method while shifting tab - angular

I am trying to call a method while tab shifting but facing bit confuse. I am using 'click' but this is working while click of any thing under that tab. Here my intention is while shifting tab, method supposed to be click. If any one have idea please help me.

This is my template class:

<tabs>
<tab heading="It's First tab" (click)="firstTab()">
       First tab content
</tab>   
<tab heading="It's Second tab" (click)="secondTab()">
       second tab content
</tab>   
<tab heading="It's Third tab" (click)="thirdTab()">
     third tab content
</tab>     
</tabs>

Upvotes: 0

Views: 876

Answers (1)

Federico Galfione
Federico Galfione

Reputation: 1109

As you can see from the component documentation there is an EventEmitter called selected that is emit every time the tab is selected. So try to change your code with something like this:

<tabs>
    <tab heading="It's First tab" (selected)="firstTab()">
        First tab content
    </tab>   
    <tab heading="It's Second tab" (selected)="secondTab()">
        second tab content
    </tab>   
    <tab heading="It's Third tab" (selected)="thirdTab()">
        third tab content
    </tab>     
</tabs>

Upvotes: 1

Related Questions