3

AngularJSの. _ また、いくつかのAngularUI Bootstrapコンポーネントとスタイリング、およびその他のBootstrap タブも使用しています。$stateviews

今私が疑問に思っていたのは、リンクをクリックして新しいタブがロードさui-srefれた後に、 と組み合わせて特定のタブをアクティブにする方法があるかどうかということです。view

元。内の 2 番目のタブに直接リンクするがあるDashboard view場所にいますlinkTest view

ダッシュボード html

<div class="panel">
   <div class="panel-heading">
       <h4">Go to Test view and activate Image tab</h4>
   </div>
   <div class="panel-body">
       <a ui-sref="app.test({id: id})" class="btn btn-info">Test</a>
   </div>
</div

html をテストする

<tabset class="nav-tabs-alt" justified="true">
    <tab>
        <tab-heading>Information</tab-heading>
        <div class="Content">...</div>
    </tab>
    <tab>
        <tab-heading>Image</tab-heading>
        <div class="Content">...</div>
    </tab>
</tabset>
4

1 に答える 1

3

active属性を使用して、タブがアクティブかどうかを表す変数を使用します。私のコードでは、 というスコープ変数を使用していますimageActive

 <tabset class="nav-tabs-alt" justified="true">
    <tab active="informationActive">
        <tab-heading>Information</tab-heading>
        <div class="Content">...</div>
    </tab>
    <tab active="imageActive">
        <tab-heading>Image</tab-heading>
        <div class="Content">...</div>
    </tab>
</tabset>

次に、リンクをクリックしてこの変数を適切に設定すると、2 番目のタブがアクティブになります。

 <a class="btn btn-info" ng-click="imageActive= true;">Test</a>
于 2016-02-09T14:59:28.570 に答える