Questions tagged [canactivatechild]
7 questions
39
votes
5 answers
Angular's "CanActivate" interface is deprecated. How to replace it?
My Angular app includes a simple AuthGuard as shown below and there has never been a problem with it. Recently, I upgraded my Angular version from 15.1.4 to 15.2.0 and since then, my IDE indicates that both CanActivate and CanActivateChild are…

kellermat
- 2,859
- 2
- 4
- 21
2
votes
1 answer
angular 9 why canActivateChild start befor canActivate completed?
in my program I have a func in canActivateChild that need to occur
after canActivate finished , but the child component loads befor canActivate of the parent finish,why?
my routing-module:
const routes: Routes = [
{
path: '',
component:…

Hinda
- 21
- 2
1
vote
3 answers
How to apply canActivate guard for all routes(master route and all sub routes) in Angular
I use Angular Guard to protect my routes, i add canActivate attr in master route and it works fine, while for sub single routes(ReportsRouteModule/RequestsRouteModule...), if i want to enable guard, i alse need to set canActivate in each routes, i…

Rollsbean
- 715
- 2
- 11
- 31
1
vote
0 answers
Prevent Routing To Secondary View If Page Refresh In Angular going into recursion
I am developing "Prevent Routing To Secondary View If Page Refresh In Angular" code from : https://www.bennadel.com/blog/3368-prevent-routing-to-secondary-view-if-page-refresh-in-angular-5-0-0.htm
I have developed below code, but code is going into…

PAA
- 1
- 46
- 174
- 282
0
votes
1 answer
Route between components under the same lazy module without activating the canActivateChild
I have a component named FirstComponent and its location is in /hub/first. The hub-routing module has a check for each route and looks like this:
const routes: Routes = [
{
path: '',
canActivateChild: [HubGuard],
children: [
{
…

Udi Mazor
- 1,646
- 2
- 15
- 30
0
votes
1 answer
Angular Routing to Child path based on role
After successful login, I redirect to following path
this.router.navigate(['/main/'])
Based on role received from login. Is it possible to redirect to diff modules.
Example: If Role is 'Admin' if I redirect to ['/main'] based on role it will…

raviguggilam
- 17
- 6
0
votes
0 answers
On click, redirect to a route for which canActive returned false once
I have a guard on a route with 3 children. I land in a ZeroStateComponent when I do not have data. In the ZeroStateComponent, I have a Get started button which is supposed to land me to the Admin route again.
Nothing is happening when I click on…

Empty
- 350
- 2
- 4
- 22