Sugandh Srivastav
Sugandh Srivastav

Reputation: 11

router.navigation() is not working in remote-app with module federation in Angular

router.navigate is not working when using the internal routing in the remote-app.

I am using module-federation and trying to use router.navigate in it but somehow when I am trying to use router.navigate in the remote app (learn) to navigate to todo component it is not navigating only the url is getting changed.

The component is not getting changed. Here, I am attaching the github link where I had pushed my changes.

Github Link(use master branch): https://github.com/SugandhSrivastav/Module-Federation/tree/master/mono-workspace

Description: router.navigate is not working when using the internal routing in the remote-app. I am using router.navigate to navigate from learn component to todo component when using the module federation but the url is changing, component is not changing.

Steps-to replicate: To deploy it use ng serve host-app for shell-app and ng serve mfe-app for the remote-app.

Expected Behaviour: The routing is working fine individually for the remote-app(mfe-app) but when using it with the shell app(host-app) routing is not working as expected.

Upvotes: 0

Views: 1794

Answers (1)

F. K.
F. K.

Reputation: 964

Remove the BrowserModule from the shared module in the shared.module.ts. It only needs to exist in the app module. I made this change and I can navigate in the remote app without any issues.

Upvotes: 1

Related Questions