@HostListener('document:visibilitychange', ['$event'])
visibilitychange() {
if (this.cartProducts && this.isCartProductsChanged) {
const blob = new Blob([JSON.stringify(this.cartProducts)], { type: 'application/json' });
navigator.sendBeacon("http://localhost:3000/api/shopping-online/get-beacon", blob)
this.isCartProductsChanged = false;
}
}
public cartProducts: CartItem[] = [];
public isCartProductsChanged: boolean = false;
@HostListener('click', ['$event.target']) onClick(e){
window.alert('Current DOM element is');
console.log(e);
}
@HostListener('click', ['$event']) onClick(e) {...}