Constructor() Vs ionViewDidLoad()

Upon calling services and getting data setting up the page , is it better to put everything in the constructor() or ionViewDidLoad(), I know viewDidload() won’t get called again if we return to the page that has been rendered is that correct?

1 Like

If you are lazy loading, put as little in the constructor as possible. That will let your page pop up “immediately” and then get filled in over time. Beyond that, yes, ionViewDidLoad contains things you only want created once per instantiation of the page, while ionViewWillEnter contains things you want done each time the page becomes the active view.

10 Likes

Good explanation. Very helpful.

Many thanks @AaronSterling ! Your reply is so useful.