title: How to get query parameters from URL in Angular 5?
body: <p>I'm using angular 5.0.3, I would like to start my application with a bunch of query parameters like <code>/app?param1=hallo&amp;param2=123</code>. Every tip given in <a href="https://stackoverflow.com/questions/35688084/how-get-query-params-from-url-in-angular2/37962626">How to get query params from url in Angular 2?</a> does not work for me.</p>
  
  <p>Any ideas how to get query parameters work?</p>
  
  <pre><code>private getQueryParameter(key: string): string {
    const parameters = new URLSearchParams(window.location.search);
    return parameters.get(key);
  }
  </code></pre>
  
  <p>This private function helps me to get my parameters, but I don't think it is the right way in new Angular environment.</p>
  
  <p>[update:]
  My main app looks like</p>
  
  <pre><code>@Component({...})
  export class AppComponent implements OnInit {
  
    constructor(private route: ActivatedRoute) {}
  
    ngOnInit(): void {
      // would like to get query parameters here...
      // this.route...
    }
  }
  </code></pre>