Venkat Venkat - 1 month ago 12
AngularJS Question

Display NO Data found in angularjs filter

how can i display no data found when searched record not found

here is code:


<table>
<tbody>
<tr ng-repeat="e in employee | filter :search">
<td>{{ e.Name | uppercase }}</td>
<td>{{ e.Email | lowercase }}</td>
<td>{{ e.Age }}</td>
<td>{{ e.Gender }}</td>
<td>{{ e.DeptId == "" ? 'Null' : e.DeptId}}} </td>
</tr>
<tr ng-show="search.length == 0" >
<td colspan="5"> No Data found</td>
</tr>

</tbody>
</table>

Answer

replace the search.length with (employee |filter:search).length == 0

<tr ng-show="search.length == 0" >
       <td  colspan="5"> No Data found</td>
</tr>

replace

 <tr ng-show="(employee |filter:search).length == 0" >
                    <td  colspan="5"> No Data found</td>
                </tr>