To find more information :
Questions tagged [angular-router-guards]
289 questions
1
vote
0 answers
Angular 12: Resolve guard redirects to its current component instead of navigating to its destination
When you log in you should be redirected to the dashboard page. When we navigate to the dashboard we are going to do a resolve so that the data is already loaded even before we can see the page. When we go directlry to the link of the dashboard I am…

Gilles
- 11
- 1
1
vote
3 answers
Anglar 13 route guard (canActivate) only works on first page load
Solution found - since the solution is much shoerter than the problem, I add it here:
The problem was not the guard (even though I optimized the guard by using map / switchMap operator instead of new Obeservable), but the Subject, that I used to…

Stiegi
- 1,074
- 11
- 22
1
vote
2 answers
How can I get an angular route guard, or the service it calls, to wait for a response before evaluating the boolean?
I'm trying to implement some basic logic in a route guard to verify that a user is authorized to access a URL.
When a user clicks on a link from a list, I'm grabbing the firestore document ID and passing that ID as a URL parameter to the next page.…

Rusty Shackleford
- 57
- 1
- 9
1
vote
1 answer
NgRx how to wait for the end of an Effect execution
How to wait for the completion of an Effect in NgRx.
I am stuck in this situation. I have an effect that loads a token from the storage and the dispatch an action to update the Store depending that the token was found or not.
autoLogin$ =…

akuma8
- 4,160
- 5
- 46
- 82
1
vote
0 answers
Auth guard - angular - toastr service is not working
export class AuthGuard implements CanActivate {
constructor(private accountService:AccountService, private toastr:ToastrService){}
canActivate(): Observable {
return this.accountService.currentUser$.pipe(
map(user => {
…

Zyad Tarek
- 21
- 1
- 2
1
vote
0 answers
Angular: My left nav will collapse if there is a route change. Is it possible to prevent it to collapse?
I am using my company's own UI library to define my left nav items:
export const appNavItems: NavItem[] = [
{
name: 'Request',
route: '/request',
subItems: [
{
name: 'View Requests',
…

zhinee
- 105
- 1
- 10
1
vote
1 answer
Infinite loop using window.location on an Angular Guard
So i need to start this Angular13 application based on the user role trough a JWT.
If the user is "superorganizer" then i need to render certain view but if the user is "organizer" then i need to render another view.
After some research I tried to…

Nico Alvarez
- 81
- 9
1
vote
1 answer
Router does not navigate to targeted component
I have a function that redirects a user to a page Orders if the user's state is complete, and to a HOME page if the user's state is not complete.
The Orders page has a GuardService that implements canActivate, and the HOME page does not have any…

smillis12
- 111
- 5
1
vote
1 answer
Redirect to common error.component.html with Authguard
I'm trying to handle errors in Angular using Guards.
I have a role.guard that allows the user to get in certain paths depending on its role. I also have an auth.guard that does the same but depending on the authorization.
The role guard looks like…
user16241255
1
vote
3 answers
Authorization based on roles
Is there a way to easily handle authorization based on roles with the lib angular-auth-oidc-client?
As soon as a user is on the site, I want to identify them, so I use the auto-login-all-routes guards, and this far everything is ok for me. But I'd…

Itori
- 33
- 6
1
vote
0 answers
Angular guard instantiated before injected service
I have an Angular guard that uses data from injected service to determine if a route can be accessed, like so:
@Injectable({
providedIn: 'root'
})
export class MyGuard implements CanActivate {
constructor(private someService: SomeService,…

dzenesiz
- 1,388
- 4
- 27
- 58
1
vote
0 answers
prompt for a password on each tab change within the URI - Angular 7
I have a /admin URI and inside this there are 3 sub tabs
Model Tracker
…

Manojkumar
- 1,351
- 5
- 35
- 63
1
vote
0 answers
Angular router.navigate not working for child routes in canActivate()
I have 2 child modules in my application in which i have used lazy loading. In canActivate Guard() i have set a condition that if the child module has products then navigate to the home page else navigate to the shop page.
But the below conditions…

Nidhin Kumar
- 3,278
- 9
- 40
- 72
1
vote
2 answers
Angular Guard Not Called on Route Path that Redirects
So, there can be entry to my app in multiple ways.
http://localhost:4200 and http://localhost:4200/home
If the link to my app (from an outside app) has a query param on it, I want to grab it. I created a QueryParamCheckGuard which is…

ScubaSteve
- 7,724
- 8
- 52
- 65
1
vote
1 answer
How to export Angular 10 guard using DOCUMENT for public-api
I have an Angular 10 library that has a guard. I want to export the guard to use on the consuming application's router. I went the path of exporting the guard in my public-api.ts but I get a build error that Document type cannot be resolved. I'm…

RadianceBox
- 13
- 3