Question: I'm using angular 5.0.3, I would like to start my application with a bunch of query parameters like `/app?param1=hallo&param2=123`. Every tip given in [How to get query params from url in Angular 2?](https://stackoverflow.com/questions/35688084/how-get-query-params-from-url-in-angular2/37962626) does not work for me.

Any ideas how to get query parameters work?

```
private getQueryParameter(key: string): string {
  const parameters = new URLSearchParams(window.location.search);
  return parameters.get(key);
}

```

This private function helps me to get my parameters, but I don't think it is the right way in new Angular environment.

[update:]
My main app looks like

```
@Component({...})
export class AppComponent implements OnInit {

  constructor(private route: ActivatedRoute) {}

  ngOnInit(): void {
    // would like to get query parameters here...
    // this.route...
  }
}

```

Answer: 
Found in: [Parent components gets empty Params from ActivatedRoute](https://stackoverflow.com/questions/42947133/parent-components-gets-empty-params-from-activatedroute)

Worked for me:

```
import {Component, OnDestroy, OnInit} from '@angular/core';
import { Router, ActivatedRoute, Params, RoutesRecognized } from '@angular/router';

@Component({
  selector: 'app-navigation-bar',
  templateUrl: './navigation-bar.component.html',
  styleUrls: ['./navigation-bar.component.scss']
})
export class NavigationBarComponent implements OnInit, OnDestroy {
  private sub: any;
  constructor(private route: ActivatedRoute, private router: Router) {}

  ngOnInit() {
    this.sub = this.router.events.subscribe(val => {
      if (val instanceof RoutesRecognized) {
        console.log(val.state.root.firstChild.params);
      }
    });
  }

  ngOnDestroy() {
    this.sub.unsubscribe();
  }

}

```
When you have an empty route object, it's mainly due to the fact that you are not using a router-outlet in your app.component.html.

Without this, you won't be able to get a meaningful route object with non empty subObjects, particularly params & queryParams.

Try to add `<router-outlet><router-outlet>`just before calling your`<app-main-component></app-main-component>`

Before that, make sure you have your query param ready in app-routing > which export the class Route used by App component : 

```
param: '/param/:dynamicParam', path: MyMainComponent

```

Last thing of course, to get your param, I personnaly use `this.route.snapshot.params.dynamicParam` where dynamicParam is the name used in your app-routing component :)