toddmotto / angular-component

Fully featured .component() polyfill for Angular v1.3+
https://toddmotto.com
Other
191 stars 30 forks source link

Add support for `require` object and $onInit controller method #17

Closed bisubus closed 8 years ago

bisubus commented 8 years ago

Technically they are the features of directives and not components, but it would require too much fragile patching in versions prior to 1.5.

Directives can live fine without them, but they are essential for intercomponent communication, components have no alternatives to link and thus are barely usable without them.

Can we add them, please?

toddmotto commented 8 years ago

Do you think polyfilling this would be achievable? Unsure if there are things here that rely on Angular internals.

bisubus commented 8 years ago

@toddmotto Absolutely. I believe it has to be something like this. It seems to be quite close to what $compile does in 1.5.

toddmotto commented 8 years ago

Awesome. Do you think hi-jacking the Controller would be better and then running this.oninit first?

bisubus commented 8 years ago

Yes, I'm quite sure about that, that's what is done under the hood. All required controllers are available as instance properties when $onInit runs on instance, that's its purpose.

I fixed it, it should be preLink to maintain the proper order of $onInit execution.

toddmotto commented 8 years ago

Sounds good to me, let's get this added!

bisubus commented 8 years ago

Ok. It looks like there's nothing to break down here.

pablolazaro commented 8 years ago

Hi there,

On my project we are really interested on using this polyfill mainly for the $onInit method.

Do you have scheduled the merge of that pull request?

Thank you very much.

toddmotto commented 8 years ago

Hey. Super busy at moment, will try land it this week, you can pull in the code from the PR for now though if you'd like as a temporary solution!

On 14 March 2016 at 11:40, Pablo Lázaro notifications@github.com wrote:

Hi there,

On my project we are really interested on using this polyfill mainly for the $onInit method.

Do you have scheduled the merge of that pull request?

Thank you very much.

— Reply to this email directly or view it on GitHub https://github.com/toddmotto/angular-component/issues/17#issuecomment-196274079 .

@toddmotto