Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block routing if form is dirty [ Angular 2 ]

I am blocked with this,
In Angular 2, I need to block any user click event, even browser refresh if the form in the page is dirty

Could you help me with ideas?

like image 661
Matt Avatar asked Sep 11 '25 18:09

Matt


1 Answers

It seems you are looking for canDeactivate

It allows you to block routing away. You would need a shared service where you update the forms dirty state so that the guard can access it.

like image 95
Günter Zöchbauer Avatar answered Sep 14 '25 09:09

Günter Zöchbauer