ngUpgraders / ng-forward

The default solution for those that want to write Angular 2.x style code in Angular 1.x
411 stars 36 forks source link

Instantiate Component Controller During Post Link Phase #109

Open timkindberg opened 9 years ago

timkindberg commented 9 years ago

I think we should wait until the post link phase until we invoke the Component's controller function. This way we'll know that we can have access to the child directives/components and they'll be fully linked and ready to go. This is a prerequisite to being able to query child components with @ContentChild and @ViewChild.

timkindberg commented 9 years ago

This shows the phases and how they are ordered: http://stackoverflow.com/questions/24615103/angular-directives-when-and-how-to-use-compile-controller-pre-link-and-post

MikeRyanDev commented 9 years ago

Another idea is to keep controller instantiation as-is, perform lookup during the link phase, and then call the controller's onInit lifecycle hook at that point. Might be a safer option and it leverages part of our Angular 2 polyfilling plans.

timkindberg commented 9 years ago

Ah yes... I think that might be more how Angular 2 works anyway.