I have a table component, where I am printing the array data using *ngFor.
<ng-container *ngFor="let element of array | search: searchInput">
<tr>
<td class="body_summary curved-border-table-left">
<span
class="count-5"
[class.update-plugins-second]="element ['status'] === 'unread'"
[class.update-plugins]="element ['status'] === 'read'"
></span>
<span class="inner_text"> {{ report["title"] }} </span>
</td>
</tr>
</ng-container>
Here, I have written custom search pipe like this
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
name: "search",
})
export class SearchPipe implements PipeTransform {
transform(reports: string[], searchInput: string): any[] {
if (!searchInput) {
return reports;
}
searchInput = searchInput.toLowerCase();
return reports.filter((x: any) =>
x?.title.toLowerCase().includes(searchInput)
);
}
}
In this case, search functionality is working fine, but I want to add an empty state as
<p> No Records Found </p>
when no records are found in the search pipe.
Where should I write markup for this after current *ngContainer and how should I do this?