7

I have these lines in my router:

..
    canActivate: [MyGuard], 
    path: "search",
    component: SearchComponent,
    data: {
        accessRoles: [roleAdmin, roleUser]
    }
..

I want to limit access to SearchComponent by canActivate of MyGuard.

Is it possible to get this data array from canActivate?

Thank you in advance!

Egor
  • 2,122
  • 2
  • 21
  • 23

1 Answers1

8
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
  console.log(route.data)
}
Rahmat Ali
  • 1,430
  • 2
  • 17
  • 29
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • 1
    Yes, it works. OMG I spent lots of time but the answer it so simple. Thank you very much! – Egor Sep 09 '16 at 10:56