I am trying to close a boostrap modal after i navigate to a page. However when i navigate to the page the modal stays open. I tried to use the close method from the activeModal class but still stays open. This is my code:
viewNewLocationPage(): void {
this.router.navigate(['/locations/new']);
this.activeModal.close();
}
CodePudding user response:
Close the modal before you navigate? Navigation happens instantly, so code afterwards doesn't execute. Or subscribe to navigate event and close it on event.
viewNewLocationPage(): void {
this.activeModal.close();
this.router.navigate(['/locations/new']);
}
CodePudding user response:
you can try do like this:
this.router.navigate(['/locations/new']).then(() => this.activeModal.close());