Questions tagged [angular-route-guards]

89 questions
0
votes
2 answers

Unexpected behavior when routing to children with componentless route in Angular 5

I have an question about Angular 5 routing. If I declare routes like this below, the route guard is called every time I route to one of the components via routerLink in html. const routes: Route[] = [ { path: 'comp1', component: Comp1Component,…
0
votes
1 answer

can activate route guard angular cannot satisfy interface while executing logic

I have the following can activate route guard class import {OnDestroy } from '@angular/core'; import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; import {Injectable} from…
user9487981
0
votes
3 answers

How to wait for asynchronous http subscription to complete in multilevel nested function

I am new to Rxjs. I am trying to implement a canActivate guard for my nativescript-angular app. Basically, if the user has JWT token in the storage, it will try to check for the JWT validity from the server, and land on the homepage if the token…
0
votes
1 answer

Angular 4 - How to redirect to parent route when launching a child route url directly?

The requirement is very simple. When a Child Route/Component's URL is entered directly in the browser, I should be able to redirect it to the parent route. Questions : 1. How to identify a page refresh or if a child route is being launched…
0
votes
0 answers

Angular - I'm having trouble getting canDeactivate working with my modal for a route

Scenario: Tech: Angular version 5 app using typescript and webpack. I Have made a canDeactivate guard to see if a users wants to leave the current route. When the user tries to navigate to another route a custom modal needs to appear that I've…
0
votes
1 answer

Angular 4 child route to always include param from parent

I have an Angular 4 webapp, that currently hosts a multi tenant site. An example url would be something like www.example.com/tenant/ I have setup my routes as follows, to allow myself a 'tenant guard' ensuring I always have this property before…
0
votes
0 answers

Angular 2 Guards: canLoad() Is Firing Twice any Reason?

canLoad Is Firing Twice On Rejection or Even In Acceptance export const ROUTES: Routes = [ { path: 'Inbox', canLoad: [CanActivateViaAuthGuardService], loadChildren: 'LazyLoaded module', } ] canLoad…
0
votes
1 answer

Angular 2 routing issue in child pages

I am new angular 2 development. I added one component ,Inside this component i have some other child component. My folder structure in following ways: parentComponent -child1Component -child2Component -child3Component in…
Sarath
  • 1,459
  • 3
  • 22
  • 38
-1
votes
2 answers

Angular RouteGuard "A function whose declared type is neither 'void' nor 'any' must return a value"

I have a route guard that checks if a user has access to a resource, before proceeding. After the subscription, I check if the user has access, and if not, redirect using parseUrl or return true. @Injectable({ providedIn: 'root' }) export class…
Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
-1
votes
1 answer

Route Guard based on an api call

I have a route guard in angular which returns true or false according to an api call I am using this route guard on multiple routes, my question is : does the api get called for every route I put the route guard on ? As you can see in the…
Hasan Kanaan
  • 99
  • 1
  • 11
-1
votes
1 answer

How to make http post call inside route guard in angular7?

I have an Angular 7 app in which I have a post call and on the basis of that post call response I want to make guard active/inactive. I have my route guard like this canActivate = (_router: ActivatedRouteSnapshot): boolean => { console.log('in…
Fahad Hassan
  • 781
  • 10
  • 20
-1
votes
2 answers

Check if "data" contain items of Array

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean { return new Promise((resolve, reject) => { this.securityService.securityActions().subscribe( data =>…
-1
votes
1 answer

Route Guard: How to make route guard true based on list sent by the server?

I was trying to use route guard in my app that should let you go to a component only if the server sends you some parameters. This is the list of the parameters that the server can send me (not all of them are sent each time) AGREEMENTS_VIEW …
-2
votes
2 answers

Disable router navigate link based on conditions

How can I disable the router.navigate or the link, based on a status? If the status is a "No" then i can't type the link to edit the Materials? HTML
1 2 3 4 5
6