File tree Expand file tree Collapse file tree 3 files changed +6
-1
lines changed Expand file tree Collapse file tree 3 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 2727 < div class ="box ">
2828 < a href ="/socks/{{ sock.id }} ">
2929 < div class ="img-box ">
30- < img src ="sock-images/Socks-{{ sock.brand }}-{{ sock.variant }}.png " />
30+ < img src ="sock-images/Socks-{{ sock.brand }}-{{ sock.variant }}.png " (error) =" onImageError($event) " />
3131 </ div >
3232 < div class ="detail-box ">
3333 < h6 > {{ sock.name }}</ h6 >
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ export class ShopComponent {
2323 public currentPageSubject = new BehaviorSubject < number > ( 1 ) ;
2424 public pageSize = 10 ;
2525
26+ placeholderImageUrl = 'images/placeholder.jpg' ;
27+
2628 constructor ( private socksService : SocksService ) { }
2729
2830 ngOnInit ( ) : void {
@@ -75,4 +77,7 @@ export class ShopComponent {
7577 this . currentPageSubject . next ( page ) ;
7678 }
7779
80+ onImageError ( event : Event ) {
81+ ( event . target as HTMLImageElement ) . src = this . placeholderImageUrl ;
82+ }
7883}
You can’t perform that action at this time.
0 commit comments