AngularJS: Show elements based on filtered results

If you ever need to show a container only if the filters of the repeated elements have one or more results, then you can do it using this code.


<input
ng-model='searchText'/>
<span ng-show='filtered.length > 0'> <ul>
<li ng-repeat='el in filtered = (model | filter:searchText)'>
<div>{{el.label}}</div>
</li>
</ul>
</span>

Source: StackOverflow

Leave a Reply

Your email address will not be published. Required fields are marked *