Questions tagged [angular-guards]
123 questions
0
votes
0 answers
Angular adding `resolve` guard affecting page layout
I'm trying to add a resolve to a component. But when I add resolve, if affects the page layout. The component gets probably absolute position and get out of the parent component grid. Any idea how I can fix this. When I remove resolve, all works…

Ahmad Raza
- 129
- 2
- 13
0
votes
1 answer
Angular CanActivate doesn't route to new route when refresh token api is called even when returning true
I have been working on adding route guard and token interceptor in an Angular 6 project.
In the route-guard's canActivate, I call an async method which checks, if the access token has expired:
If yes, checks for refresh token expiry and if that has…

Rohan Agarwal
- 2,441
- 2
- 18
- 35
0
votes
1 answer
CanDeactivate guards does not runs as expected, after pressing browser back button
I have implemented canDeactive guard, once browser button is clicked it popups a Model and ask Yes/No.
After clicking on No it stays on the same page and Again if i press the back button the popup appears and after clicking No/Yes button it…

Rohit Vaidya
- 3
- 4
0
votes
1 answer
Angular 7.3 how to get data from the route
I want to pass the current URL from the app.routing.ts file to the guard because there is a problem where the url gets reset in the guard for some reason. Below I added how I pass the data to the route.
const appRoutes: Routes = [
{
path: '',
…

Djkobus
- 131
- 1
- 2
- 8
0
votes
2 answers
Angular BehaviourSubject Subscribe not updated when called from component and guard
I'm sorry if my question looks silly.
I try to implement behaviorsubject in my service and then call it from my login component.
This is my service
private currentTokenSubject: BehaviorSubject;
public currentToken:…

Ahfa
- 180
- 8
0
votes
1 answer
Ngrx two guards for a route at logout the second doesn't trigger
I've got these routes:
{
path: 'admin',
canLoad: [AuthGuard, AccountGuard],
loadChildren: () =>
import('./features/admin/admin.module').then(m => m.AdminModule),
data: { preload: false }
},
{
path: 'auth',
…

Whisher
- 31,320
- 32
- 120
- 201
0
votes
1 answer
Angular Firebase Guards, block routing with specific roles
Hi Angular Developers,
Please I need your help, I need to block routing with specific roles, This is my Doc with profiles:
My angular guards return and object with profiles: {admin: true, current: false}
import { Injectable } from…

lyonTypescript
- 125
- 1
- 3
- 10
0
votes
2 answers
Angular guards isn't working as supposed to
I am trying to redirect new users (no authentication involved) to a country selection for using the application for the first time.
I am using angular guards, and I am lazy loading.
I am checking following this link:…

Don-Ricardo
- 213
- 4
- 12
0
votes
1 answer
ActivatedRoute params is empty in CanActivate guard
I have generic guard for many applications:
export class Guard implements CanActivate {
constructor(private authService: AuthService, private router: Router, private route: ActivatedRoute) {}
async canActivate(route: ActivatedRouteSnapshot)…

yantrab
- 2,482
- 4
- 31
- 52
0
votes
0 answers
API call executing twice
Im using role guards . A user can access certain routes only if user has certain rights. The user rights are fetched from backend using a service called login service inside app root component and is stored in a set inside a configuration service.…

Mohit Harshan
- 1,916
- 1
- 18
- 41
0
votes
1 answer
Angular7: Global Guard - CanDeactivate interface
I am very new to Angular, and was unsuccessful in finding an answer to what I am searching for.
The problem I am facing right now is that all the global error messages are not disappearing when I switch to another route.
I tried to solve this…

Torjescu Sergiu
- 1,483
- 10
- 24
0
votes
2 answers
Error while implementing CanDeactivate Guard
I'm currently trying to implement a CanDeactivate Guard to my angular application which already had HTTP Interceptor to resolve for authentication.
But adding the CanDeactivate guard is throwing Error as mentioned below.
I have registered the Class…

Debadatta Meher
- 83
- 2
- 10
0
votes
1 answer
How to do API call in Angular 7 route's matcher function
I have a route matcher function in Angular 7, need to do API call to get array and check if that array contains URL slug
What i tried:
I called API on APP_INITIALIZER and saved it on localStorage, problem is that i have Angular Universal that don't…

Abzal Zhumabaev
- 11
- 6
0
votes
1 answer
Angular Guard CanLoad Unit Testing
I'm relatively new to Angular 7, having come from AngularJS, I've written a guard implementing CanLoad which stops users without the correct claims loading a module. It checks whether the user is logged in and whether the user has a claim that's…

John McArthur
- 916
- 1
- 12
- 30
0
votes
2 answers
Lazy load module on same path based on guard
I want to load a specific Angular Module based on a user role on the same ("") path (home). Let's say, I have two modules named AdminModule and OperatorModule. If the role is ADMIN then I want to load the AdminModule otherwise the OperatorModule. I…

Yanick van Barneveld
- 302
- 3
- 18