Questions tagged angular-router-guards

Explore the latest questions and answers asked by our top developers.

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 check it in user subscription for that route and then redirected to any of […]

The guard does not work the second time in angular 11

I am configuring a guard for my angular app and it happens that when I run the application and log in the first time it works fine, but I configure an error interceptor where I have a condition that when the user receives a 401 error from the api it returns it at login. and […]

trigger canActivate every 10 minutes

I am currently using a canActivate-service for my angular parent route and therefore for all the childroutes. looks like that for example const routes: Routes = [ { path: ”, canActivate: [ServiceWhichShouldRunEvery10Minutes], runGuardsAndResolvers: ‘always’, children: [ { path: routeA, component: a, }, { path: routeB, pathMatch: ‘full’, component: b, },… canActivate-method async canActivate(route: ActivatedRouteSnapshot, state: […]

Angular – how to improve local development experience?

Currently I’m building Angular 12 based project. ​ It has custom CanActivate guard, which communicates with some services using 3rd party library. ​That library also requires https to pass all authentication flow. I’ve started from this: Updated hosts file and added custom host there like: 127.0.0.1 customhost.local.test.com Updated angular.json => serve section with host and […]

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 an user is on the site, I want to identify him, so I use the auto-login-all-routes guards, and this far everything is ok for me. But I’ld like to allow access only if the userData contains a […]

Route Guard Angular – How to reconize a reload page instead of a load page via URL (manually change). How can I differenciate the two cases?

RouteGuard class As you can see from the picture, I have a Route Guard that has to admit the navigation to a specific page only if the user is logged (first part) and only if the page is called from code and not modifing the URL path. My problem is that my project has also […]

Angular Guards: Prevent to manually access an URL but authorize refresh

I’ve created a Guard that prevent a user to manually access an URL and it’s working fine. The problem is that when I refresh the page, the Guard redirects me. Here’s the code: export class NavigationGuard implements CanActivate { constructor(private router: Router) { } canActivate(): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | […]

Dynamic Use of Angular Route Guard

There are two paths, let’s say, one is guest-login/:id1/:id2 and another one is shared/:id1:id2. Both these paths correspond to different components. I have another component named as Login Component (main login) and all the paths are guarded except main login and guest-login. I have a situation now. I want to guard shared/:id1:id2 path and want […]

By Shubham Baranwal
Published
Categorized as angular, angular-router-guards Tagged ,

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, Guard2], data: { –> screenAction: ‘:action’ == ‘read’ ? ‘read’ : ‘:action’, } ] I have to use the variable :action because […]

Angular-8 Throttling navigation to prevent the browser from hanging

I created sub modules and add that module routes in app.module.ts only and then import submodule in app.module.ts . when i try to render sub module’s route i am getting this error in developer console. Angular-8 Throttling navigation to prevent the browser from hanging. See https://crbug.com/882238. Command line switch –disable-ipc-flooding-protection can be used to bypass […]

By Aniket Gajjar
Published
Categorized as angular, angular-router-guards, routes Tagged , ,
1 2 3 8

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq