admin管理员组

文章数量:1287838

I'm new to the world of microfrontends and I'm facing an issue.

I have an application with a microfrontend architecture, and I'm using single-spa-angular to mount and unmount my apps when needed.

Here's my problem:

I have a page in microapp1 that contains a form. The URL is microapp1/form. On this same page, there's a button that, when clicked, navigates to a page in microapp2, at microapp2/home.

My question is: if there are unsaved changes in the form, I don’t want the navigation to microapp2/home to happen, nor do I want microapp2 to be mounted.

Regarding route navigation, if I move from microapp1/form to microapp1/home while having unsaved data, I can use Angular's canDeactivate guard to prevent navigation. However, this guard does not seem to work when navigating between different microfrontends.

My questions are:

1- Why does canDeactivate work only between routes within the same microfrontend?

2- Is there a way to use a guard (or something similar) to prevent navigation between different microfrontends in single-spa? Any guidance would be greatly appreciated!

本文标签: routesPrevent navigation between microfrontends in singlespaangularStack Overflow