Вы можете добавить скрытый div и отобразить его, используя ngIf. В вашем html:
<div class='empty-result' *ngIf="empty">
No result found.
</div>
В вашем .ts:
empty: boolean = false;
getUsers(searchParam: string = '') {
this.userService.getUsers(this.page, this.limit, searchParam).subscribe(
if (data.length === 0) {
this.empty = true;
} else {
this.empty = false;
}
(data: any) => {
this.users = data.results;
this.loading = false;
this.totalRecords = data.totalRecords;
this.limit = data.limit;
this.totalPages = Math.ceil(this.totalRecords / this.limit);
},
(errors) => {
this.loading = true;
this.errmsg = errors.error.message;
}
);
}
Вы можете установить тайм-аут, чтобы скрыть сообщение после его отображения.