您可以创建自己的自定义过滤器,如documentation所示。
{{ filter_expression | filter : array : expression : comparator}}
您需要在此处提供一个功能,如expression
。
因此,让我们假设您要根据值是否包含搜索文本进行过滤。您将在控制器中创建一个函数:
$scope.customFilter = function(value) {
// value parameter is the value passed in each ng-repeat
// In your example, it is the measure variable in "ng-repeat measure in
// newSearchResults
if (value.indexOf($scope.TypedText) !== -1) {
return true;
} else {
return false;
}
};
如果在自定义过滤函数返回true,该值显示否则它不是。
然后,您可以使用自定义过滤器就像任何其他过滤器:
<div ng-repeat="measure in newSearchResults | filter:customFilter()">
//Repeating tags here
</div>
已经answered..Please检查这一点,它可能是有益 http://stackoverflow.com/questions/20179546/filter-ng-repeat-elements-from-the-beginning-of-the-string –