如何使用angularjs在同一页面中切换标签?

时间:2016-07-14 07:08:39

标签: javascript angularjs

<tabset class="overflowhidden marginbottom0" tabset-name="clientTabset">

<tab heading="General" title="general">
<p>Hello</p>
<button  ng-click="general()"  class="btn btn-primary"  has-permission='CREATE_CLIENT'>Next</button>
</tab>

<tab heading="Address" title="address" >
<p>hello world </p>
</tab>

</tabset>

我想在点击下一步按钮

后将标签从常规标签切换到地址标签

2 个答案:

答案 0 :(得分:2)

您好,您可以尝试使用active true

<强> JS

$scope.active = {
    one: false,
    two: true
  };

<强> HTML

 <tabset>
    <tab heading="General" title="general">
        One
         <button  ng-click="general()"  class="btn btn-primary"  has-permission='CREATE_CLIENT'>Next</button>
      </tab>
      <tab heading="Address" title="address"  active="active.two">Two</tab>
    </tabset>

供参考https://plnkr.co/edit/nRHFHDByvcQhiQTDkbFh?p=preview

答案 1 :(得分:0)

的javascript

$scope.general = function () {
  $scope.active = 1;
}

HTML

<tabset class="overflowhidden marginbottom0" tabset-name="clientTabset" active="active">

  <tab heading="General" title="general" index="0">
    <p>Hello</p>
    <button ng-click="general()" class="btn btn-primary" has-permission='CREATE_CLIENT'>Next</button>
  </tab>

  <tab heading="Address" title="address" index="1">
    <p>hello world</p>
  </tab>

</tabset>

参考:https://github.com/angular-ui/bootstrap/tree/master/src/tabs