Every component in Ionic has a lifecycle. Ionic creates, renders the component, checks it when its data-bound properties change and destroys it finally. Ionic offers lifecycle hooks that provide a way to tap into these key moments and trigger an action when they occur.
Ionic 2 & 3 had these lifecycle events : ionViewDidLoad, ionViewWillEnter,
ionViewDidEnter, ionViewWillLeave, ionViewDidLeave, ionViewWillUnload,
ionViewCanEnter, ionViewCanLeave.
* ionViewDidLoad : Fired only when a view is stored in memory, will not fire if view has been already cached.
* ionViewWillEnter : fired when entering a page, before it becomes active one. this event is triggered every time user enters in the view.
* ionViewDidEnter : fired when entering a page, after it becomes active page.
* ionViewWillLeave : fired when user leaves a page, before it stops being the active page.
* ionViewDidLeave : fired when user leaves a page, after it stops being the active page.
* ionViewWillUnload : fired when a view is going to be completely removed.
* ionViewCanEnter : this is a nav guard. fired before entering a view. Useful when you want to control access to pages based on access credentials.
* ionViewCanLeave : this is also a nav guard, fired before leaving a view.
Allows you to control whether user can exit the view or not Ionic 4 provides the Angular lifecycle hooks in addition to the above listed Ionic lifecycle hooks. All the angular lifecycle hooks are available.
* ngOnChanges, ngOnInit, ngDoCheck, ngAfterContentInit, ngAfterContentChecked,
* ngAfterViewInit, ngAfterViewChecked, ngOnDestroy.