Using "or" in expressions in filter, angularJS -
from docs: object: pattern object can used filter specific properties on objects contained array. example {name:"m", phone:"1"} predicate return array of items have property name containing "m" , property phone containing "1".
is possible return array containg property name: "m" or phone: 1?
or have write custom filter this?
ng-options="m.mc_title m in maincategories | filter:{mc_schema:activeschema.sch_id, all:true}"
the above code filters both properties has true (&&). want filter if of them true (||).
i believe that, that, should define own filter handles 'or' expressions parameters. here's example did you:
http://plnkr.co/edit/qwjm2fy6jmdwyg2yr2it?p=preview
// receive json properties serve or clause. // example, 1 give object name john or id 123. $scope.model.filtereddata = $filter('orarray')($scope.model.data, {name: 'john', id: '123'});
the name of filter 'orarray' , receives 2 things:
- the list of elements want filter
- a json properties want filter by, specified
{filterproperty: filtervalue}
edit: added inline filter plnkr
<li ng-repeat="element in model.data | orarray:{name: 'john', id: '123'}">
Comments
Post a Comment