Reputation: 8912
I have added basic functionality where user can enter any student name to filter out the records from table. It works fine.
However, i need to enhance this functionality like "Show message no record found when no record found"
<input type="text" ng-model="searchKeyword">
<tr ng-repeat="student in students |filter: searchKeyword">
<td style="text-align: left;" width="296;">{{student.FirstName}} {{student .LastName}}</td>
Any hint please?
Upvotes: 0
Views: 1064
Reputation: 7201
You can easily save a result of a filter like this:
<tr ng-repeat="student in (filteredStudents = students | filter: searchKeyword)">
And then it's just as easy as:
<span ng-show="filteredStudents.length === 0">no record found when no record found</span>
Upvotes: 0
Reputation: 8091
Something like the following no ?
<div ng-show="!(students.length > 0)">No Students Found! Call the COPS!</div>
This is just a conditional view. Which as you can see, will only display id the results count is not greater than 0! :)
Or even better :
<div ng-show="!(students| filter:searchKeyword).length">No Students Found</div>
ref: ng-show when array length is zero
Upvotes: 1