Angularjs filters OR conditions -


i trying create filter can conditionally select multiple attributes of same variable. example

var list = [ {id: 1, state: 'u'}, {id: 2, state: 'p'} ]

<div ng-repeat="item in list| filter:{state:'u'}>

this result in id 1 being displayed.

<div ng-repeat="item in list| filter:{state:'p'}>

this result in id 2 being displayed.

how can create filter display id's have state:'p' or state:'a'

neither of below work:

<div ng-repeat="item in list| filter:{state:'p' || 'a'}>

<div ng-repeat="item in list| filter:({state:'p'} || {state:'a'})>

hope below code snippet might ! run :)

var app = angular.module('app', []);  app.controller('ctrl', function($scope) {            $scope.list = [{      id: 1,      state: 'u'    }, {      id: 2,      state: 'p'    }, {      id: 3,      state: 'a'    }];      $scope.state = function(item) {          return (item.state == 'p' || item.state == 'a');      };    });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    <div ng-app="app" ng-controller="ctrl">      <div ng-repeat="item in list | filter:state">        {{item.id}}      </div>    </div>


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -