a8m / angular-filter

Bunch of useful filters for AngularJS (with no external dependencies!)
https://github.com/a8m/angular-filter
MIT License
2.93k stars 332 forks source link

BroupBy hide parent when filtering #257

Closed ahmedmrj closed 7 years ago

ahmedmrj commented 7 years ago

Hello, I am using groupBy filter for creating nested tree from object, and I want to hide parent on filtering with an input. if it doesn't have any matching child.

My html code look like this:

<div>
<input type="text"  ng-model="mySearchFilter">
<ul>
  <li ng-repeat="(key, value) in players | groupBy: 'team'">
    Group name: {{ key }}
    <ul>
      <li ng-repeat="player in value | filter: mySearchfilter">
        player: {{ player.name }}
      </li>
    </ul>
  </li>
</ul>
</div>
fikoborquez commented 7 years ago

You can use filterBy before groupBy team in the first repeat instead of filtering in the second repeat. I made an example.

ahmedmrj commented 7 years ago

yess!!! many thanks fikoborquez.