user5593728
user5593728

Reputation:

How to detect the Browser refresh and Close events in Angular JS?

Hi i have tried the below event to detect but sometimes it doesn't fire the event, while closing the tab or Browser.

$window.onbeforeunload

Upvotes: 0

Views: 2788

Answers (1)

miladdn131
miladdn131

Reputation: 72

if you want only browser close do something and you do want when refresh page yuo can use this code:

   window.onbeforeunload = function () {
    if (performance.navigation.type == 1) {
        localStorageService.remove("authorizationData");
    }
}

Upvotes: 1

Related Questions