From 3dda7312ea532debd45c4668a4856d80bef89f54 Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Thu, 19 Sep 2024 17:38:58 +0400 Subject: [PATCH] Update search.component.ts --- src/app/layout/common/search/search.component.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/layout/common/search/search.component.ts b/src/app/layout/common/search/search.component.ts index 2b6a137..f20aed7 100644 --- a/src/app/layout/common/search/search.component.ts +++ b/src/app/layout/common/search/search.component.ts @@ -33,6 +33,7 @@ import { RouterLink } from '@angular/router'; import { angorAnimations } from '@angor/animations/public-api'; import { Subject, debounceTime, filter, map, takeUntil } from 'rxjs'; import { IndexedDBService } from 'app/services/indexed-db.service'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; @Component({ selector: 'search', @@ -78,7 +79,9 @@ export class SearchComponent implements OnChanges, OnInit, OnDestroy { private _unsubscribeAll: Subject = new Subject(); constructor( - private _indexedDBService: IndexedDBService + private _indexedDBService: IndexedDBService, + private _sanitizer: DomSanitizer + ) { } @ViewChild('barSearchInput') @@ -172,4 +175,11 @@ export class SearchComponent implements OnChanges, OnInit, OnDestroy { trackByFn(index: number, item: any): any { return item.id || index; } + + handleImageError(event: Event): void { + const target = event.target as HTMLImageElement; + target.onerror = null; + target.src = 'images/avatars/avatar-placeholder.png'; + } + }