0
這裏是我的數據:「包含」搜索對象數組的子元素
[
{profile: {name: "Test123"}}
]
我有一個文本輸入,就像這樣:
<input ng-model="searchText">
我試圖做一個使用文本框輸入搜索profile.name
。
我試圖做一個自定義過濾器,像這樣:
$scope.searchFilter = function(value){
return value.profile.name.indexOf($scope.searchText) != -1;
};
然後過濾,像這樣:
<tr ng-repeat="profile in profiles | filter: searchFilter"></tr>
似乎不幸的是,這工作正常的初始搜索,但進入時文本放入文本框中,過濾器不會被重新評估。
當我在搜索框中輸入文字時,如何強制Angular重新檢查過濾器,還是有更好的方法來做到這一點?