Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs lifecycle: $onInit not called

Tags:

angularjs

the documentation for migration from angularjs 1.5 to 1.6 says "Disabling (by default) the pre-assignment of bindings on controller instances, which helps with support for native ES6 classes." and "Initialization logic that relies on bindings being present should be put in the controller's $onInit() method, which is guaranteed to always be called after the bindings have been assigned."

I try to do this migration for our project and I observed, that for some of the controllers $onInit doesn't get called. In the official documentation I didn't find anything related to this, but there are some other sources:

https://www.tejusparikh.com/2017/universality-oninit-callback-angularjs.html

https://github.com/angular/angular.js/issues/14630

Are there other cases when the $onInit doesn't get called? Is this documented somewhere "more officially"?

Thank you!

like image 302
sanyi9 Avatar asked Apr 25 '17 10:04

sanyi9


1 Answers

I have also found that controllers Initialized by ngRoute, $onInit is not called.

like image 94
Stefdelec Avatar answered Sep 17 '22 04:09

Stefdelec