title: when i use router.getCurrentNavigation() inside ngOnInit() it gives me type error but when i use it inside constructor it works fine, why?
body: <p>Starter -</p>
  <pre><code>export class HeaderComponent implements OnInit {
  
  constructor(private route: ActivatedRoute, private router: Router) {}
  
  onClick() {
   const navigationExtras: NavigationExtras = {
     state: {
       transd: 'TRANS001',
       workQueue: false,
       services: 10,
       code: '003',
     },
   };
  
    this.router.navigate(['/auth'], navigationExtras);
   }
  }
  </code></pre>
  <p>AuthComponent -
  when using inside ngOnInit() :</p>
  <pre><code>ngOnInit(): void {
  
  this.authService.authError.subscribe(
    (error) =&gt; (this.errorMessage = error)
  );
  
  const navigation = this.router.getCurrentNavigation();
  const state = navigation.extras.state as {
    transId: string;
    workQueue: boolean;
    services: number;
    code: string;
  };
  
  console.dir(state);
  }
  </code></pre>
  <p>when using inside ngOnInit() it gives me an error :</p>
  <pre><code>core.js:5980 ERROR TypeError: Cannot read property 'extras' of null
      at AuthComponent.ngOnInit (auth.component.ts:26)
      at callHook (core.js:2486)
      at callHooks (core.js:2457)
      at executeInitAndCheckHooks (core.js:2408)`
      at refreshView (core.js:9207)
      at refreshEmbeddedViews (core.js:10312)
      at refreshView (core.js:9216)
      at refreshComponent (core.js:10358)
      at refreshChildComponents (core.js:8989)
      at refreshView (core.js:9242)
  </code></pre>
  <p>but when i place it inside constructor it works fine :</p>
  <pre><code>constructor(private authService: AuthService, private router: Router) {    
      const navigation = this.router.getCurrentNavigation();
      const state = navigation.extras.state as {
        transId: string;
        workQueue: boolean;
        services: number;
        code: string;
      };
  
      console.dir(state);
    }
  </code></pre>
  <p>so, why it works inside constructor but not inside ngOnInit ?</p>