Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: navigation for microfrontends #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

r1m
Copy link

@r1m r1m commented Aug 25, 2022

Fixes issues on module with inner routes and shell not deployed on / path.
It uses native initialize method to handle baseHRef and hashmode correclty.

Note : The method of handle router in bootstrap is not working if the module was already boostrapped.
Using deep link to inner route is not working because it does not trigger a pop_state change.

To workaround this you need to handle route init inside your component onInit method.
This is the only way I found to properly handle route changes if the component was already bootstraped once.

import { Location } from '@angular/common';
import { Router } from '@angular/router';

export class MfeComponent implements OnInit {
  constructor(private router: Router, private location: Location) {}

  ngOnInit() {
    //Using provided helper
    connectRouter(this.router, this.location);
    
    //Same thing, manually
    this.router.initialNavigation();
    void this.router.navigateByUrl(this.location.path(true));
  }
}


fix: #216, fix: #215

@puneetappcino
Copy link

how to fix this issue please help me out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants