我試圖用角過濾特定領域做一個搜索欄過濾器和這應該是一個OR
條件angularjs過濾與多個字段或條件
這是演示實現http://jsfiddle.net/tomalex0/ck19wvdx/2/。 我只想搜索Name
和Gender
而不是Location
。
無論結合我嘗試它更像AND
條件。 OR condition
filter
有內置的方法嗎?
<div ng-app="myApp" ng-controller="myController">
<input type="text" ng-model="search">
<ul>
<li ng-repeat="user in users | filter: search">{{user.Name}} | {{user.Location}}
</li>
</ul>
</div>
var data = [
{
Name: "John Smith",
Gender: "M",
Location: "Wales"
},
{
Name: "Sally Smith",
Gender: "F",
Location: "USA"
},
{
Name: "Curtis Timson",
Gender: "M",
Location: "England"
},
{
Name: "Sam Wallace",
Gender: "M",
Location: "England"
},
{
Name: "Caroline James",
Gender: "F",
Location: "Scotland"
}
];
var myApp = angular.module("myApp", []);
myApp.controller("myController", function($scope){
$scope.users = data;
});
我要排除搜索位置字段 – tomalex