2017-01-10 66 views
1

我想創建select,它顯示過濾器中元素的數量。好像是Angularjs select with filteredred elements

enter image description here

Here是PlunkR的代碼,我已經寫了。這是偉大的使他的工作,但我不能在選擇添加計數active/deactive元素。我怎樣才能做到這一點? 感謝的

+0

感謝對編輯工作後@蘇倫 - Srapyan –

回答

0

您可以在與選擇選項進行綁定之前格式化值。

<select ng-options="i as format(i) for i in statusList" ng-model="statusFilter"> 
</select> 

格式的功能是,

$scope.format = function(val) { 
    return val.status + ' ' + $scope.objs.filter(function(state) { 
     return state.status === val.value; 
    }).length; 
    } 

$scope.objs是具有active/inactive項值的陣列。

Here是工作plunkr

+0

感謝的很多,這個人是工作液太 –