2017-01-10 67 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

感谢的很多,这个人是工作液太 –