1.

In Ionic, what are the various page life-cycle events?

Answer»

Ionic makes advantage of the Angular life-cycle events. These are the life-cycle events:

  • ngOnInit: It is a one-time event that occurs during component initialization. It can be used to set up LOCAL members and make one-time calls to services.
  • ngOnDestroy: This event is triggered SHORTLY before the view is destroyed by Angular. It's useful for things like unsubscribing from observables and cleaning up.
  • ionViewWillEnter: When the component routing-to is going to animate into view, ionViewWillEnter is invoked.
  • ionViewDidEnter: When the component routing-to has done ANIMATING, ionViewDidEnter is fired.
  • ionViewWillLeave: When the component routing-from is about to animate, it fires the ionViewWillLeave event.
  • ionViewDidLeave: When the component routing-to has done animating, it fires the ionViewDidLeave event.

There are a few more lifecycle events that would prohibit users from GAINING unwanted access.

  • ionViewCanEnter: It is called before entering a view, lets you control whether or not the view can be managed by the user.
  • ionViewCanLeave: This feature is activated before the user can leave a view and allows you to control whether the view can be left or not.

Routing GUARDS can be used to replace the above two events in Ionic 4.



Discussion

No Comment Found