ng2-search-filter icon indicating copy to clipboard operation
ng2-search-filter copied to clipboard

Empty result, send messenger to the user

Open kevenjesus opened this issue 7 years ago • 4 comments

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 :)

kevenjesus avatar Aug 21 '17 19:08 kevenjesus

Does this actually work? I cant seem to make it work.

Alex61NN5 avatar Oct 04 '18 23:10 Alex61NN5

@Alex61NN5 can you provide some parts of your code?

aVolpe avatar Oct 05 '18 15:10 aVolpe

<tr *ngIf=" !(events.length) || !((events | filter: terms).length) "> <td colspan="6" class="text-center">not events result</td> </tr>

Worked for me!

navinna avatar Apr 17 '19 06:04 navinna

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>

0xMurage avatar Mar 22 '22 19:03 0xMurage