How can i call ngonint if i am navigating from angular component function
Can you give some more details or a sample demonstrating the scenario?
I'm not sure how do you navigate through the components and which ngOnInit you need to invoke.
I am trying to navigate from one component1 to some other component2,when user click on button inside ig grid
This is the button inside the iggrid
<input type='button' value='${documentId}' class='btn btn-sm btn-primary' onclick='angularComponentRef.componentFn(\"${transactionId}\")'
in component1 constructor wrote function
window['angularComponentRef'] = { zone: this.zone, componentFn: (value) => { this.test(value) }, component: this };
here i am trying to navigate to the component2
test(val1) { this.router.navigate(['/transactions/transaction/'+val1+'/PurchaseOrder']) // this.router.navigate([val]); }
Its navigated to component2 but its not calling ngOnInit() of component2
How can I fix this.Do you need any other info please let me know
I tried reproducing it and ngOnInit is actually being invoked.
Take a look at my sample. I added ngOnInit for CrisisCenterComponent and it is being called when navigating through this component.
https://stackblitz.com/edit/angular-nq8kqr-wsehqg?file=src%2Fapp%2Fcrisis-center%2Fcrisis-center.component.ts
Is there something specific on your side or can you modify my sample to replicate the behavior you are observing?