How to change class depending on filter result in AngularJS?

后端 未结 1 1142
感情败类
感情败类 2021-01-26 10:11

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

    
= 3\" >
相关标签:
1条回答
  • 2021-01-26 10:25

    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>
    
    0 讨论(0)
提交回复
热议问题