title: Subscribing to query string parameters in Angular
body: <p>I've seen quite a few examples of subscribing to query string parameters in Angular 2+ but I can't seem to get it to work</p>
  
  <p>e.g. <a href="https://stackoverflow.com/questions/35688084/how-get-query-params-from-url-in-angular2">How get query params from url in angular2?</a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>import { ActivatedRoute, Router } from '@angular/router';
  ...
  export class MyComponent implements OnInit,OnDestroy {
    private a: boolean = true;
    private b: boolean = true;
  
    constructor(route: ActivatedRoute)  {
    ...
  
    ngOnInit(): void {    
      this.route.queryParams.subscribe((queryParams:any) =&gt; {
        this.a = queryParams.a;
        this.b = queryParams.b;
       });
  </code></pre>
  
  <p>The problem I have is that <code>this</code> does not appear to refer to my component to setting <code>a</code> and <code>b</code> which I want to use to drive <code>*ngIf</code> statements does not work.</p>
  
  <p>What am I doing wrong?</p>