1

I'm accessing the URL parameters of my Angular 4 app using RouterStateSnapshot and it works just fine:

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    // state.root.queryParams will hold my URL parameters
}

the problem is that as soon as I edit my RouterModule configuration and set useHash: true the code above stops workings for some reasons because state.root.queryParams will always be null.

Why is it that? How to solve the problem?

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
  • I'm having exactly the same issue - did you ever find a resolution? – D. Lambert Mar 21 '18 at 13:27
  • not yet, otherwise I would have posted it – Francesco Borzi Mar 21 '18 at 14:07
  • Thanks -- I wound up needing to reformat parameters in order to make them work. So, "mysite/path?param=value" wound up needing to be "mysite/path/#/?param=value". I'm not thrilled with the way the hash strategy is working, but I can't get path-strategy routing to work correctly for me right now, and this will have to do. – D. Lambert Mar 22 '18 at 18:28

0 Answers0