title: Forward state with navigateByUrl in Angular
body: <p>i want to pass some data, when changing the view with navigateByUrl like</p>
  
  <pre><code>this.router.navigateByUrl(url, {state: {hello: "world"}});
  </code></pre>
  
  <p>In the next view i want to simply log the hello attribute like</p>
  
  <pre><code>constructor(public router: Router) { }
  
    ngOnInit(): void {
      console.log(this.router.getCurrentNavigation().extras.state.hello)
    }
  </code></pre>
  
  <p>When I now do it this way, i get an error:</p>
  
  <pre><code>ERROR TypeError: Cannot read property 'extras' of null
      at ProfileContactViewComponent.ngOnInit
  </code></pre>
  
  <p>Am i doing this correctly or is there a better way to pass the data between the views?
  Thanks for your help.</p>