Questions tagged [angular-router-guards]

To find more information :

289 questions
0
votes
2 answers

call api in canAcitvate - Angular

I'm trying to work with Auth guards in angular. I have a httpcall that sets a true/false value based on a response back from an HTTP call. The problems are: 1) httpClients return an observable 2) the httpClient subscription needs to happened before…
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…
0
votes
1 answer

Add navigation inside canDeactivate method

CanDeactivate Guards. Is it possible that when leaving a component, the canDeactivate not only renders a confirmation window with yes/no, but also navigates to another component? Something like this: canDeactivate(): Observable |…
0
votes
0 answers

"Cannot read property 'nodeName' of undefined" when Angular router guard canActivate returns no on route change

In an Angular 7 application where I use a router with main state and child states, a Guard helps me to prevent users to access states they cannot access at a given moment during a form filling process. So basically my Guard checks that all previous…
hms
  • 1
0
votes
2 answers

How to use an Observable in Angular route guard?

In my angular routing module, I am using a base navigation when its the default homepage, now on some condition, I want to decide which route to navigate. This is how my app routing looks. { path: '', redirectTo: 'home1', canActivate:…
Aijaz
  • 680
  • 15
  • 42
0
votes
2 answers

Angular 7 active route link loses his style?

I am using Angular 7. I have problem with routerLinkActive. When i chose link in navbar, it gives .active class to link, but when i click somewhere else on page link loses his style, but in console active class is still active. So how to keep active…
0
votes
1 answer

In Angular, is it possible to load different modules depending upon whether the user is authenticated or not?

For example, the URL: www.example.com should load one module if the user is authenticated, else it should load a different module. I have tried using guards, but it didn't work as I expect it to. I am pretty new to Angular. It would be much…
user7366809
0
votes
1 answer

condition on Angular routing

firstly, if first user already login in first tab and it will redirect to dashboard, when first user open second tab in same browser(paste login Url), automatically it will redirect to dashboard without going to login page.I had condition where in…
hafizi hamid
  • 405
  • 2
  • 20
  • 41
0
votes
0 answers

Ionic4 Angular AuthGuard works for home page and not for sign in page

I have created an Authguard for my web app and have assigned into several routes like Home, Sign-in, Sign-up etc. Expected Behavior: Home page - the intention is to show the login page if the user is not logged in Signin , Signup, Forgot Password…
0
votes
1 answer

Angular router: route not being tested by following path rule

Given the following code: const LOCALIZED_PATHS: Route[] = [ { path: 'activities', canActivate: [CountryGuard], loadChildren: 'app/common/activities/index/global/activity-index.module#ActivityIndexModule' …
0
votes
0 answers

In an Angular-router Resolver, how can one distinguish between a page refresh or initial visit versus a subsequent in-session visit

In an angular-router resolver's resolve method, is there a way to distinguish between (for lack of a better term) hard navigation (page-refreshes and first-visits within a session) and soft navigation (subsequent visits within a session by forward…
CalvinDale
  • 9,005
  • 5
  • 29
  • 38
0
votes
1 answer

Angular 6 guards blocking even when it shoundn't

I'm having a problem with angular 6 route guard. When I hit the login button, it won't redirect me to the intended route. My html calls the login() function, while the loginService.isAutenticated returns true when the doLogin() method is executed,…
Burghi
  • 15
  • 4
0
votes
1 answer

Can I read route parameter's value from the `canActivate: AuthGuard`?

{ path: ':l/bla/bla/bla', component: ..., canActivate: [AuthGuard] } Then AuthGuard's constructor: constructor( private readonly router: Router, private readonly activedRoute: ActivatedRoute) { } ... however both .params and…
0
votes
1 answer

Using onBeforeUnload screws up the browsers History in Angular

When the user is done entering data on a page, I want them to go back to the previous page (ex. Main Page -> Input Page). If I redirect them when they click submit, I will end up with a circular history (Main Page -> Input Page -> Main Page). …
0
votes
0 answers

Load module based on canLoad at runtime

Context I have a basic administration page, that has two implementations, depending on a parameter in the server. Here is the configuration I'm using for the router: { path: 'projects', loadChildren: 'app/...#ProjectsAModule', …
Supamiu
  • 8,501
  • 7
  • 42
  • 76