[英]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.