2016-06-30 50 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>