2017-08-24 142 views
-1

得到一個或力值我有一個好簡單的導航丸,我想在導航點擊獲取或力值角度:上點擊

<div style="margin-left: 32px; text-align: center"> 
    <ul id="progress-view" class="nav nav-pills" > 
     <li value="" class="active" style="margin-top: 15px"> 
      <a data-value="" data-toggle="tab">All</a> 
     </li> 
     <li data-value="505" value="0" style="margin-top: 15px"> 
      <a data-value="0" data-toggle="tab">New</a> 
     </li> 
     <li value="1" style="margin-top: 15px"> 
      <a data-toggle="tab">In Progress</a> 
     </li> 
     <li value="2" style="margin-top: 15px"> 
      <a data-toggle="tab">Waiting for answer</a> 
     </li> 
     <li value="3" style="margin-top: 15px"> 
      <a data-toggle="tab">Closed</a> 
     </li> 
    </ul> 
</div> 

謝謝!

回答

1
<ul id="progress-view" class="nav nav-pills" > 
    <li value="" class="active" style="margin-top: 15px"> 
     <a data-value="" data-toggle="tab">All</a> 
    </li> 
    <li data-value="505" value="0" style="margin-top: 15px"> 
     <a data-value="0" data-toggle="tab" 
      ng-click="clicked(0)">New</a> 
    </li> 
    <!-- etc... --> 
</ul> 

而且你的控制器

$scope.clicked = function(val) { 
    alert(val); 
} 

當然,最好是做一個角的方式:

$scope.tabs = [{ 
    title: "All", 
    value: null 
}, { 
    title: "New", 
    value: 0 
}, { 
    title: "In Progress", 
    value: 1 
}]; // etc 

$scope.tabClicked = function(tab) { 
    alert(tab.value); 
} 

而在你的看法:

<ul id="progress-view" class="nav nav-pills" > 
    <li value="{{ tab.value }}" style="margin-top: 15px"> 
     <a data-value="{{ tab.value" data-toggle="tab" 
      ng-click="tabClicked(tab)">{{ tab.title }}</a> 
    </li> 
    <!-- etc... --> 
</ul> 
+0

哎devqon ,謝謝你的重播,有沒有可能不發送參數?像這樣:var value = angular.element('#progress-view')。data('value')? – torresito