2016-06-30 51 views
0

我在uib-typeaheadng-options部分filter看起来像这样为什么我的角度过滤器不能过滤所有适当的对象?角 - 角-UI-引导

<input 
    ng-model="mergeParticipant" 
    getDisplayValue(value.name, value.age, value.membershipId) for value in participants | filter:$viewValue" 
           /> 

所调用格式化显示的功能是在这里:

$scope.getDisplayValue = (name, age, membershipId) => { 
     return age ? `${name} (${age}) - ${membershipId}`: `${name} - ${membershipId}`; 
    }; 

当我在我的输入中输入了字母bi,这是我的结果:

enter image description here

为什么没有bi的条目出现在我的列表中?我认为这可能与屏幕上的数字有关,但我在那里找不到任何图案。有任何想法吗?

+0

可能有'bi'在另一个属性未显示 – charlietfl

+0

你是对的。你如何选择只搜索显示内容? – jhamm

回答

1

考虑您的列表是这样的:

$scope.list = [ 
    {id:1, title: 'a'}, 
    {id:2, title: 'b'}, 
    {id:3, title: 'c'}, 
] 

您可以选择要应用的过滤器这样的哪个键:

<input type="text" ng-model="searchKey" /> 

<ul> 
    <li ng-repeat="item in list | filter:{title: searchKey}"></li> 
</ul>