Created
July 25, 2019 15:00
-
-
Save carusog/4d0c325b47558e44fdd3ea368cc6682c to your computer and use it in GitHub Desktop.
An Angular service to parse and get specific query parameters from URI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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