angularjs filter two values -


i'm having problem if not easy solve ta. in database have table in organizations , of them may "hidden". may not see them on list unless enter unique code given administrator. if user types code organization may appear in list.

my list looks this:

<a class="item item-avatar" ng-repeat="lugar in organizations_all | filter:search" ng-click="mostrarareas(lugar.id)" ng-if="organizations_filter !=''" ng-show="!lugar.hide">   <img image-lazy-src="{{lugar.photo}}" style="border-radius: 0 !important;">   <button class="button button-icon icon ion-plus-circled" ng-click="agregarlugar(lugar.id,lugar.private);$event.stoppropagation()" style="float: right;"></button>   <h2>{{lugar.name}}</h2>   <p class="icon ion-ios-locked" style="font-size:20px;"  ng-show="lugar.private"></p> </a> 

y mi json viene asi :

{ "count" : 5, "organization" : [ { "code" : "",     "hide" : false,     "id" : "1",     "name" : "odebret advisors ltda.",     "private" : false   },   { "code" : "",     "hide" : false,     "id" : "2",     "name" : "mop ruta 5 sur (scl - talca)",     "private" : false   },   { "code" : "",     "hide" : false,     "id" : "3",     "name" : "mop ruta 5 norte (scl - los vilos)",     "private" : false   },   { "code" : "",     "hide" : false,     "id" : "4",     "name" : "lixsys spa",     "private" : true   },   { "code" : "lxspa",     "hide" : true,     "id" : "5",     "name" : "prueba oculta",     "private" : false   } ], "status" : 1 } 

as can see, there "hide" field if true, must hide organization , "code" field code find , must entered full whereas if filter name, can discriminate 1 point on.

edit: assuming code contained in filter:search parameter, since didn't specify user typing code.

you'd better off creating own filter:

.filter('esvisible', function () {   return function (lugares, search) {     var lugaresvisibles = [];     (var = 0, ii = lugares.length; < ii; i++) {       if (!lugares[i].hide) {         lugaresvisibles.push(lugares[i]);       } else if (lugares[i].code == search) {         lugaresvisibles.push(lugares[i]);       }     }     return lugaresvisibles;   }; }); 

if using js utility library lazyjs, simplify loop pretty easily.

in end ngrepeat this:

ng-repeat="lugar in organizations_all | esvisible:search" 

note: untested, idea.


Comments