Questions tagged [angular-guards]

No instructions have been provided for the application of this tag … at this time!

Register the canDeactivate guard dynamically and trigger a confirmation prompt for navigation

Is it possible for a component to autonomously set up the canDeactivate guard in order to prompt or prevent user navigation with confirmation options like Yes/No? I am exploring this possibility due to the large scale of the application and how workflow c ...

Steps to handle Angular's response to an HTTP 401 error

I am using nodejs (express) as a server side and angular 6 as the client. On the server, I have a middleware function that checks for a session. If the session is invalid or does not exist, I want to send a response to the client so it can handle it accord ...

Encountering a type 'any' issue with the Authentication guard injection in Angular 17

I implemented a functional guard in Angular 17 import { Inject } from '@angular/core'; export const checkoutGuard: CanActivateFn = (route, state) => { const customerService = Inject(CustomerService); const router = Inject(Router); ...

Angular 6 triggers NavigationCancel event when encountering valid guards

I'm encountering difficulties with the Angular router while trying to navigate to a specific state. Despite my attempts to utilize a custom guard with canLoad() and canActivate() functions that return true, I have not been successful. The Angular documen ...