To find more information :
Questions tagged [angular-router-guards]
289 questions
3
votes
2 answers
wait for state in resolver (ngrx)
right now I have a resolver calling standard service and returning an Observable:
return this.someService.getData()
.map(data=> data.json())
I want to replace it with ngrx effects and store. When resolver is run I want to dispatch…

Jarosław Rewers
- 1,059
- 3
- 14
- 23
3
votes
1 answer
Angular 2 router CanActivate how to redirect to 404 but still show the url being visited
Here's my scenario:
A user visits a route called /protected. In my CanActivate guard, I check whether the user is logged in. If they are not logged in, I want to render my 404 route, but still show /protected in the address bar. I want users to be…

Simonxca
- 648
- 1
- 6
- 18
2
votes
1 answer
Behavior Subject Becomes Null When Changing routes
I am trying to set up a check to make sure a user is authenticated in my header component to give access to routes that are only available for logged in users. That part works, however when I try to use one of those routes after I am logged in, it…

Nolan Hovis
- 45
- 6
2
votes
1 answer
How to pass parameter to guard?
I have project-based angular 12.
I need to secure a route based on a parameter which is colled token:
export const authenticationRoutes = [
{
path: 'reset-password/token/:token',
component: ResetPasswordShellComponent,
canActivate:…

Michael
- 13,950
- 57
- 145
- 288
2
votes
1 answer
How to write AuthGuard in Ionic/Angular with AngularFire7 that works on iOS?
I'm running into an odd problem with my Ionic/angular app.
I'm using
"@angular/core": "~13.2.2"
"@capacitor/core": "3.4.0"
"@capacitor/ios": "3.4.0"
"@angular/fire": "^7.2.0"
"firebase": "^9.6.6",
It works well on the web-version and Android, but…

Dennis V
- 51
- 3
2
votes
1 answer
redirect user to home page when user does not have any permission in angular13
I have a home page and menu and I want to redirect user to home page when search URL does not permission for user.
Thanks if anyone can help.

ali memar
- 262
- 2
- 9
2
votes
1 answer
Custom Page Permission using Angular 11
I am working on an application in which I am implementing custom permission. There is subscription-based permission that I can't check in auth guard which will be static and I have implemented helper for permission which checks for route and then…

Kamran Khan
- 1,042
- 10
- 21
2
votes
1 answer
Angular - Dynamic routing with router param vaiable
I want to do something like this in my routing.module.ts (see lines marked by-->)
export const routes: Routes = [
path: 'test/:action',
component: CreateComponent,
--> canActivate: ':action' == 'read' ? [Guard1] : [Guard1,…

Ben Saad
- 21
- 4
2
votes
1 answer
How to redirect to an Angular custom made Login page if the user is not logged in
In my current case I have an Angular application with Azure AD and MSAL v2 implementation. What I want to achieve is when the user is not logged in redirecting them to the custom made Login page with a simple Login (click)="login()" button. I've…

dtkturpal
- 21
- 4
2
votes
1 answer
angular - How to create a canActivate guard to only allow redirects from another component?
I have a component that I wish to allow it's access only in case of a redirect from another component.
So if I put the url in the browser it wouldn't allow me to access it but, if I redirect to it from another specific component like this it will be…

wazzup
- 39
- 7
2
votes
1 answer
Angular routing same path different guard
I want to use the same path ticket because I want to redirect when save something (Use same component to Update Ticket ).
But there is a problem with canActivate. What is the best way to fix it?
const router: Routes = [
{
path: '',
…

Puthxii
- 47
- 9
2
votes
1 answer
angular2: call canDeactivate for same route and component but different parameters
In my application, there are multiple links with the same route but with different queryParams and fragment.
for example, I have links…

Hamid Taebi
- 357
- 2
- 12
2
votes
1 answer
Angular Router Guard not called on back button press
I have an Angular app running inside an iframe that has a route guard for the module that I'm running. The route guard is activated whenever I navigate to the page using links inside the app or through the address bar, and routes the app to the…

Flame of udun
- 2,136
- 7
- 35
- 79
2
votes
1 answer
Is it possible to guard a method in Angular?
I was wondering if it's possible to guard a method in an Angular app instead of a route. Let's say you have a button, if you click it and are not logged in, you would be redirected to the login page.
thanks

Remaori
- 95
- 1
- 9
2
votes
0 answers
Store/Restore partial form values on route change in Angular
How would you implement saving partially filled forms when navigating between routes?
Eg. User starts filling a form, but decides to navigate to a different route and then go back to original the form.
In usual case, when component is destroyed, all…

takeshin
- 49,108
- 32
- 120
- 164