简体   繁体   English

如何在更改选项卡时获取UI Bootstrap选项卡以发送事件

[英]How to get UI Bootstrap Tabs to send an event when tab is changed

<uib-tabset type="tabs">
  <uib-tab heading="Event Workflow Activities">
    <div ng-include src="'webapp/event/EventWorkflowActivities.tpl.html'"></div>        
  </uib-tab>
</uib-tabset>

I am using UI Bootstrap Tabs like above, is there any way to get broadcast an event when you switch between tabs? 我正在使用上面的UI Bootstrap选项卡,当你在标签之间切换时有没有办法让广播事件?

You can use the select attribute on the tab to execute a function in your controller that does the broadcast. 您可以使用选项卡上的select属性在执行广播的控制器中执行一个功能。 Like this: 像这样:

<uib-tabset type="tabs">
    <uib-tab heading="Event Workflow Activities" select="tabSelected()">
            <div ng-include src="'webapp/event/EventWorkflowActivities.tpl.html'"></div>        
    </uib-tab>
</uib-tabset>

Add the select attribute like above that points to a function in your controller. 添加上面的select属性,指向控制器中的函数。 I named this one tabSelected(); 我把它命名为tabSelected();

Now in your controller create the function: 现在在你的控制器中创建函数:

$scope.tabSelected = function () {
    //Broadcast or emit your event here.

    // firing an event upwards
    $scope.$emit('yourEvent', 'data');

    // firing an event downwards
    $scope.$broadcast('yourEvent', {
      someProp: 'value'
    });
};

Take a look at the documentation for more information. 查看文档以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 angular ui bootstrap选项卡组件:未单击选项卡处于活动状态时如何获取选项卡内容 - angular ui bootstrap tabs component: how to get the content of a tab when the tab is active not clicked 如何在angularjs中使用UI引导程序选项卡的内容动态地激活选项卡? - how to Dynamically Active tab with content for ui bootstrap tabs in angularjs? 在AngularUI引导程序中动态设置选项卡(ui.bootstrap.tabs) - Dynamically set tab in AngularUI Bootstrap (ui.bootstrap.tabs) 当列改变位置时如何获取事件? - how to get event when column changed it position? ui.bootstrap.tabs如何知道angularjs控制器中哪个选项卡处于活动状态 - ui.bootstrap.tabs how to know which tab is active in angularjs controller Angularjs-ui bootstrap.tabs-添加下一个选项卡按钮 - Angularjs-ui bootstrap.tabs - Adding Next tab button 使用Angular UI Bootstrap在动态创建的选项卡上设置活动选项卡 - Setting active tab on dynamically created tabs with Angular UI Bootstrap Angular-ui引导程序选项卡-是否有防止选择选项卡的方法? - Angular-ui Bootstrap Tabs - Is there a way to prevent tab selection? UI Bootstrap和带选项卡的模式:第一个选项卡带有边框 - UI Bootstrap and modal with tabs: the first tab is focused with a border Angular-Bootstrap UI选项卡:“删除”选项卡选项 - Angular-Bootstrap UI Tabs: Remove Tab Option
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM