This question already has an answer here:
angularjs filtering multiple expressions
                                
                                    (1个答案)
                                
                        
                                4年前关闭。
            
                    
摆弄:http://jsfiddle.net/L3wra2kL/1/

我期望的是:
搜索:“ house paris”->结果如下:Sell house in Paris

我真的不知道该怎么做:将单词分开并使其成为过滤器的“ OR条件” ...

任何想法?

最佳答案

您可以制作自己的自定义过滤器。这是与您提供的示例集成的简单实现示例

过滤

app.filter('contains', ['$filter', function(filter) {
    return function (collection, query) {
        var arr = query ? query.toLowerCase().split(/\s+/) : [];
        for (var i = 0; i < arr.length; i += 1) {
            collection = filter('filter')(collection, arr[i]);
        }
        return collection;
    }
}]);


Working Fiddle

08-05 21:26