Skip to content Skip to sidebar Skip to footer

How To Change Class Depending On Filter Result In Angularjs?

I cannot work out how to change the style of a class depending on the status/result of the filter. My code:

Solution 1:

You can assign your filter results to a intermediary variable and than use that variable to conditionally apply your class:

<div ng-if="search.length >= 3">
  <div ng-class="{list: filteredItems.length}" style="margin-top: 30px;">
    <a 
      class="item item_recipe" 
      ng-repeat="item in filteredItems = (items | nonBlankFilter:search | filter:search)" 
      ng-click="$emit('search.click',item.PK);"
    >
      <img class="thumbnail" src="images/thumbnails/{{item.THUMB}}">
      <div class="title">{{item.TITLE}}</div>
    </a>
  </div>
</div>

Post a Comment for "How To Change Class Depending On Filter Result In Angularjs?"