| 56 | } |
| 57 | |
| 58 | @Injectable({providedIn: 'root'}) |
| 59 | class MyCanActivateGuard { |
| 60 | allow: boolean = true; |
| 61 | redirectTo: string | null | UrlTree = null; |
| 62 | |
| 63 | constructor(private router: Router) {} |
| 64 | |
| 65 | canActivate(): boolean | UrlTree { |
| 66 | if (typeof this.redirectTo === 'string') { |
| 67 | this.router.navigateByUrl(this.redirectTo); |
| 68 | } else if (isUrlTree(this.redirectTo)) { |
| 69 | return this.redirectTo; |
| 70 | } |
| 71 | return this.allow; |
| 72 | } |
| 73 | } |
| 74 | @Injectable({providedIn: 'root'}) |
| 75 | class MyResolve { |
| 76 | myresolve = of(2); |
nothing calls this directly
no test coverage detected