Skip to content

Instantly share code, notes, and snippets.

@carusog
Created July 25, 2019 15:00
Show Gist options
  • Save carusog/4d0c325b47558e44fdd3ea368cc6682c to your computer and use it in GitHub Desktop.
Save carusog/4d0c325b47558e44fdd3ea368cc6682c to your computer and use it in GitHub Desktop.
An Angular service to parse and get specific query parameters from URI
import {URLSearchParams} from '@angular/http';
export class QueryParamService {
get(name: string) {
const params = new URLSearchParams(window.location.search.substring(1));
const param = params.get(name);
return param === null ? null : decodeURIComponent(param);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment