在移动标签时调用方法 - 角度

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在移动标签时调用方法 - 角度相关的知识,希望对你有一定的参考价值。

我试图在标签移动时调用一个方法但面临一点混乱。我正在使用“点击”但这是在点击该标签下的任何内容时工作。这里我的意图是移动tab,方法应该是click。如果有任何想法请帮助我。

这是我的模板类:

<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>
答案

正如您在组件documentation中看到的那样,每次选择选项卡时都会发出一个名为selected的EventEmitter。因此,尝试使用以下内容更改代码:

<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>

以上是关于在移动标签时调用方法 - 角度的主要内容,如果未能解决你的问题,请参考以下文章