<input ng-model="query" name="query">
store the filter results in filteredData:
<ul>
<li ng-repeat="todo in filteredData = (todos | filter:query">{{todo}})"</li>
</ul>
then check filteredData's length to conditionally show a warning:
<p ng-show="filteredData.length==0">There are no todos for given query</p>
Hope it helps,
John.
On Tuesday, July 3, 2012 8:24:46 AM UTC-6, Jakub Arnold wrote:
I have a list created via ng-repeat with a filter:query and I want to be able to show an element if there are no elements left by the filter.
Basically my idea would be something like this, where I assign a class based on the count of the displayed elements
<input ng-model="query" name="query">
<ul>
<li ng-repeat="todo in todos | filter:query">{{todo}}</li>
</ul>
<p class="display-{{something like todos.length}}">There are no todos for given query</p>
The problem is, that .length doesn't get updated with the filter, and something like todos.count() doesn't work.
What is the proper way of doing this?