javascript - Open accordion if clicked OR search query > 0 (not sure how to do the OR part) -


i'm trying accordion open if user has typed search bar or if clicks open accordion, got them work separately can't both work @ same time.

if

<accordion-group is-open="status.open" ng-repeat="cat in cats | filter: query"> 

the accordion opens when user clicks, , if

<accordion-group is-open="query.length > 0" ng-repeat="cat in cats | filter: query"> 

the accordion open after user has searched something

is there way put 2 together? i've tried didn't work

<accordion-group is-open="query.length > 0 || status.open" ng-repeat="cat in cats | filter: query"> 

here's code in jsfiddle http://jsfiddle.net/gol848jn/3/

you need inside controller

$scope.$watch("query",function(newv){     if(newv != undefined){         if(newv.length > 0){                $scope.open = true;                $scope.$apply;         }else{                $scope.open = false;                $scope.$apply;         }      }     }); 

and accordion

<accordion-group is-open="open" ng-repeat="cat in cats | filter: query">             <accordion-heading style="padding:0px;"> <i class="glyphicon" ng-class="{'glyphicon-minus': open, 'glyphicon-plus': !open}"></i>&nbsp;&nbsp;{{cat.title}}</accordion-heading>     

working fiddle http://jsfiddle.net/0ynqomrt/


Comments