ng2-search-filter
ng2-search-filter copied to clipboard
Empty result, send messenger to the user
Hey guys,
if a result is empty, using is code
(events | filter: terms).length === 0
for exemple
<tr *ngIf="events.length === 0 || (events | filter: terms).length === 0">
<td colspan="6" class="text-center">not events result</td>
</tr>
Thanks a your plugin! it`s amazin :)
Does this actually work? I cant seem to make it work.
@Alex61NN5 can you provide some parts of your code?
<tr *ngIf=" !(events.length) || !((events | filter: terms).length) ">
<td colspan="6" class="text-center">not events result</td>
</tr>
Worked for me!
for future you, use the as
keyword to alias the results and avoid double data filter processing. e.g.
<tbody *ngIf="(events|filter:term) as rows">
<tr *ngFor="let row of rows; let i=index">
<!-- display your data here-->
</tr>
<!-- empty state i.e. when there is no data and user is searching-->
<ng-container *ngIf="isSearching && rows.length==0">
<tr class="no-data">
<td colspan="6" > No data matching the filter criteria</td>
</tr>
</ng-container>
</tbody>