Run Code When Leaving Your Angular Application
summary
Claims that ngOnDestroy not fired on refresh or tab close, demonstrates that Angular doesn’t destroy components on browser refresh so the lifecycle hook is skipped, and shows a working fix: add a @HostListener('window:beforeunload', ['$event']) method that logs the event. The demo runs in the browser, the console shows the beforeunload handler firing, and the talk gives concrete uses like clearing local/session storage or logging users out which are proved to work.
AI-written summary · about
related talks
21mTimely matter: when does Angular execute your code?
09mCommon Angular Gotchas
32mClean Up Your Dom By Using The Full Power Of Angular Host Elements
34mHigh-Performance Applications with Angular
47mTaking over the web platform with Angular 2
19mTuning Your Angular Application
22mOffline Angular app in action
34mBad Practices, how you should NOT do in Angular world
