Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
Reading a query string parameter inside an Angular 4 guard?

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.

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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);
}
about 4 years ago · Santiago Trujillo Report

0

Or if you are using parameter in your route:

canActivate(route: ActivatedRouteSnapshot) {
  console.log("Id:", route.params['uid']);
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!