Issue
I'm trying to read a query string parameter inside the canActivate
method of an Angular guard. Unfortunately, the queryParams
parameter from both ActivatedRouteSnapshot
and RouterStateSnapshot
are empty, even though the query string exists.
Example: bla.com/?uid=123
That query string parameter can be sent to any URL and i want my guard to be able to look at it.
Solution
Example url: http://example.com/oper/sale?code=you_code_here
import { ActivatedRouteSnapshot } from "@angular/router";
...
canActivate(route: ActivatedRouteSnapshot) {
console.log("code", route.queryParams.code);
}
Answered By - Ontil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.