Angular 10Javascript

Angular 10 show popup alert on window close

angular 10 show popup alert before window close

Hello to all, welcome to therichpost.com. In this post, I will show you, Angular 10 show popup alert on window close.

Angular show alert before window close

Post Working:

Hi friends, In this post, I am telling you the code for open alert popup before window or tab close and for this I have used HostListener Decorator, who listens the events.

Why this post made?

I was doing some my personal practice for angular on form submission and I did this and I am sharing with you but you can use this code in many ways like on for submission, question answers applications, gaming applications. Please share your views on this.

Angular10 came and for basics understanding please check the below tow links:


Here is the code snippet for Angular 10 show popup alert on window close:

1. Here is the code snippet and I have used that into my src/app/app.component.ts file to detect the window or tab close events:

...
import { HostListener } from '@angular/core';
export class AppComponent {
  ..
  @HostListener('window:beforeunload', ['$event'])
  beforeunloadHandler(event) {
    return false;

    //I have used return false but you can your other functions or any query or condition
  }
}

This is it friends and if you have any kind of working doubt then please check above video once or have any kind related to this post then do comment below.

Jassa

Thanks

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.