'How do I prevent paramMap without pageId to trigger in Angular Modal?
I am using some standard code with paramMap to detect a pageId. When no pageId is detected the app routes you back to home. However when I open this page in a modal of course there is no pageId. Is there a way to detect that the page was opened in a modal and thus no navigation to home is performed? the pageId is still needed for navigation.
this.route.paramMap.subscribe((paramMap) => {
if (!paramMap.has('pageId')) {
this.navCtrl.navigateBack('/home');
return;
}
this.extractedPage = Number(this.route.snapshot.paramMap.get('pageId'));
if (this.pageWithinBounds(this.extractedPage)) {
this.activePage = this.extractedPage;
return;
}
this.router.navigate(['/home']);
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
