Answers for "hostListener"

0

hostListener

@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;
Posted by: Guest on July-29-2021

Browse Popular Code Answers by Language