I am using Angular 9 (Ivy). I want to trigger router Guards without actually changing the page. With the current abilities of Angular, how can I accomplish this?
This following is example code that does not work but should give an idea of what I am trying to do.
In the template:
<button type="button" (click)="triggerGuards()">Trigger</button>
In the component:
public triggerGuards(): void {
// this `navigate()` call does *not* trigger Guards //
this._router.navigate([this._router.url]).then(() => {
this._doSomethingElse();
});
}
I also tried this._router.navigateByUrl(this._router.url + '?')
but this does not fire the Guards either.
How can I trigger router Guards without changing pages?