Angular: Prevent route change if any changes made in the view

后端 未结 4 1011
余生分开走
余生分开走 2021-02-06 23:31

If I have a form in a view (Angular). When user tries to navigate away from there, and I want a confirmation message to appear. How can I do that?

4条回答
  •  感动是毒
    2021-02-07 00:35

    CanDeactivate can be used for that. You need to pass the status to a service that is accessible to canDeactivate.

提交回复
热议问题