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
This problem is likely coming from that fact that you are not terminating your subscriptions using ngOnDestroy. Here is how to get'ter done.
Bring in the following rxjs subscription import.
import { Subscription } from 'rxjs/Subscription';
Add OnDestory to your Angular Core Import.
import { Component, OnDestroy, OnInit } from '@angular/core';
Add OnDestory to your export class.
export class DisplayComponent implements OnInit, OnDestroy {
Create a object property with a value of Subscription from rxjs under your export class for each subscription on the component.
myVariable: Subscription;
Set the value of your subscription to MyVariable: Subscriptions.
this.myVariable = this.rmanagerService.getRPDoc(books[i].books.id).subscribe(value => {});
Then right below ngOninit place the ngOnDestory() life cycle hook and put in your unsubscribe statement for your subscription. If you have multiple, add more
ngOnDestroy() {
this.myVariable.unsubscribe();
}