angularjs - Hide div when there are no result due to a filter -
how can know when there no results display due filter?
<input type="text" class="form-control" ng-model="search" placeholder="search..."> <div ng-show="contents.length !== 0"> <h2>contents</h2> <div class="panel panel-default" ng-repeat="content in contents | filter:search"> <div class="panel-heading"> <h3 class="panel-title">{{content.title}}</h3> </div> <div class="panel-body">{{content.description}}</div> </div> </div>
see solution working in plunker
simply using trick.
ng-show="(contents | filter:search).length !== 0"
Comments
Post a Comment