Angular · Middle · Question 33 of 75

How do you warn the user before leaving a page with unsaved changes?

Explanation

CanDeactivateFn<EditPage> receives the component instance and can return confirm(...). beforeunload only covers closing or reloading the tab, not router navigation.

Further reading

Problem with a question

Angular · Middle · question 33

Test yourself

Take the Angular · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz