如何使用angularjs标签指令时,移动到第二个选项卡上的一个按钮的点击 [英] How to move to second tab on click of a button when using angularjs tab directive

查看:496
本文介绍了如何使用angularjs标签指令时,移动到第二个选项卡上的一个按钮的点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我采用了棱角分明标签directive.The链接,JS是小提琴
AngularJs标签指令。我的问题是我怎么可以移动到第二个选项卡,从第一个标签一个按钮,点击?谢谢

Hi I'm using angular tab directive.The link for JS fiddle is AngularJs Tab Directive .My Question is How can I move to second tab from first tab with click of a button?Thanks

 <tabs>
<pane title="First Tab">
  <button type="button" ng-click="moveToSecondTab()">Second Tab.</button>
</pane>
<pane title="Second Tab">
  <div>This is the content of the second tab.</div>
</pane>

推荐答案

而不是在HTML文件的硬编码窗格,从控制器读取它。
类似 $ scope.tabs = [
    {标题:动态标题1,内容:动态内容1},
    {标题:动态标题2,内容:动态内容2,禁用:真正}
  ];

Instead of hardcoding the panes in your HTML file, fetch it from your controller. Something like $scope.tabs = [ { title:'Dynamic Title 1', content:'Dynamic content 1' }, { title:'Dynamic Title 2', content:'Dynamic content 2', disabled: true } ];

再从你的HTML可以调用函数来切换活动标签。事情是这样的:
$ scope.moveToSecondTab =功能(){
            $ scope.tabs [1]。主动=真;
    };

Then from your HTML you can call the function to switch the active tab. Something like this : $scope.moveToSecondTab = function () { $scope.tabs[1].active = true; };

但是,它会如果不是一个功能,直接从按钮切换活动标签更好。

However, it'll be better if instead of a function, you switch the active tab directly from the button.

使用这样的:

&LT;按钮NG点击=标签[1]。主动=真正的&GT;选择第二个选项卡&LT; /按钮方式&gt;

这里以供参考。

这篇关于如何使用angularjs标签指令时,移动到第二个选项卡上的一个按钮的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆