title: How to add guard with modal window?
body: <p>I wanna add dialog window, with yes and no answers, after we click on router link, and if chose yes, we pass canActivate guard.</p>
  
  <p>But after we change route and come buck to that router with guard again, us state will bee saved and no matter what we chose in dialog window, and we may pass guard before we chose answer in dialog window. How fix that?</p>
  
  <p>guard service</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import {AuthService} from './auth.service';
  import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
  import {DialogWindowComponent} from '../../Components/DialogWindow/dialog-window.component';
  import {MatDialog} from '@angular/material/dialog';
  
  @Injectable({
    providedIn: 'root'
  })
  export class AuthGuardService implements CanActivate{
      result: boolean;
      constructor(public dialog: MatDialog) {}
  
      openDialog(): void {
          const dialogRef = this.dialog.open(DialogWindowComponent, {
              width: '250px',
          });
  
          dialogRef.afterClosed().subscribe(result =&gt; {
              console.log('The dialog was closed');
              console.log(result);
              this.result = result;
          });
      }
  
      canActivate(
          next: ActivatedRouteSnapshot,
          state: RouterStateSnapshot): boolean {
          this.openDialog();
          console.log('AuthGuard#canActivate called');
          return this.result;
      }
  }
  </code></pre>