Nan*_*ncy 2 search pipe angular
我正在使用下面的搜索管道来显示记录集,并将管道名称附加到HTML文件中。下面的管道将在搜索栏中获取用户键入的值,并根据用户键入的输入显示记录。在下面的代码中,我试图根据病例编号和患者姓名搜索记录,这很好。但是我不确定如何处理未找到记录。当用户在搜索栏中键入内容,并且如果没有记录时,我需要显示一条消息“找不到记录”。
You can create a variable that contains the filter pipe result and check the length of the result array .
<ng-container *ngIf="( nonFinalArList | pksearch:searchNonFinalData) as result">
<div *ngFor="let nonFinalArList of result; let i = index"> </div>
<p *ngIf="result.length === 0">No Result</p>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
Using Pipe Results in Angular Templates