Ionic 6 Oninit works only once

Issue

Ionic router run OnInit only first time.
I have an Ionic application. But OnInit only works once, so there is an alternative.
I have version 6.11.1 of Ionic.

Solution

OnInit is an Angular lifecycle hook. Your objects are likely staying on the stack and are therefore simply re-rendered and thus not triggering onInit.

Since this is an Ionic application you should look at using ionViewDidEnter.

https://ionicframework.com/docs/angular/lifecycle

Answered By – user796446

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published