-1

how to read values from query string in angular 5

the url format is following https://www.test.com/test?id=13467tdgbgfhjfgy

  • 1
    Please share code where you tried so we can guide you. – Paresh Gami Oct 10 '19 at 07:26
  • Possible duplicate of [How to get query parameters from URL in Angular 5?](https://stackoverflow.com/questions/47455734/how-to-get-query-parameters-from-url-in-angular-5) – sa_n__u Oct 10 '19 at 07:40

1 Answers1

1

In your component, you can access to query parameters with ActivatedRoute.

constructor(private route: ActivatedRoute) { }

ngOnInit() {
  this.route.queryParams.subscribe(params => {
    console.log(params['id']); // 13467tdgbgfhjfgy
  });
}

https://alligator.io/angular/query-parameters/

Zooly
  • 4,736
  • 4
  • 34
  • 54