I am calling router.navigate
on same page with some query string parameters. In this case, ngOnInit()
does not call. Is it by default or do I need
I've had the same issue, additionally I got the warning:
did you forget to call `ngZone.run()`
This site provided the best solution:
import { Router } from '@angular/router';
import { NgZone } from '@angular/core';
...
constructor(
private ngZone:NgZone,
private _router: Router
){ }
redirect(to) {
// call with ngZone, so that ngOnOnit of component is called
this.ngZone.run(()=>this._router.navigate([to]));
}