1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Ignore can-activate guard by passing parameter in router.navigate

Discussão em 'Angular' iniciado por profiler, Setembro 17, 2024.

  1. profiler

    profiler Guest

    I am looking for a solution to ignore one-time guard by passing parameter/flag/etc. in router navigate.

    Current configuration:

    • standard routing with auth canActivate: [CanActivateGuard]
    • resolver - checking the subpath application - for loading snapshot, when the user got URL with some path, can load application,

    Problem:

    • above mechanism working great (snapshot, generate lost ngrx store data etc.)
    • but in guard I am checking if some value exists in store:

    canActivate(): boolean {
    let canActivate = false;
    this.store$.pipe(select(selectSth), take(1)).subscribe(item => {
    if (!!item) {
    return canActivate = true;
    }
    this.router.navigate(['/main']);
    return canActivate = false;
    });
    return canActivate;
    }
    }

    • canActivate was checked before resolver - so I can't navigate to /main path even the parameter exists in store

    Question:

    There is any solution to add parameter to this.router.navigate and one time avoid guard?

    Continue reading...

Compartilhe esta Página