The (Almost) Universality of the $onInit Lifecycle Callback in AngularJS

  • AngularJS 1.x’s Component functionality brought with it new lifecycle callbacks that are not restricted to controllers within Components.
  • The sample code shows that in almost every case where you use a Controller , you can use the $onInit callback.
  • AngularJS always has a way of keeping developers on their toes.
  • Far from being dead, AngularJS is incorporating new functionality that keeps it a solid alternative to the newer frameworks that have appeared.
  • This means that if you have pre Angular 1.5 code and want to upgrade to Angular 1.6, you can and should use $onInit everywhere except for Controllers that are used for routes, which you will have to keep using the previous way.

AngularJS 1.x’s Component functionality brought with it new lifecycle callbacks that are not restricted to controllers within Components.

@vi_jedi: Where you can and where you can’t use the $onInit callback in AngularJs 1.x:

that are used for routes, which you will have to keep using the previous way. AngularJS always has a way of keeping developers on their toes.

The (Almost) Universality of the $onInit Lifecycle Callback in AngularJS