r/angularjs • u/toddmotto • Nov 13 '15
Exploring the Angular 1.5 .component() method
http://toddmotto.com/exploring-the-angular-1-5-component-method2
u/-pertinax- Nov 13 '15
Nice summary Todd. I was interested by this when I first heard about it at AngularConnect but at the time there were no docs, and the only mention I could find was in a pending pull request on GitHub. I also really like the fact that you included those snippets from the actual Angular source. Makes it clear exactly what is going on there.
2
u/toddmotto Nov 14 '15
Thank you! And yes likewise, so I did a little reading of the source and found it super useful, glad you liked the source snippets! :D
1
u/dvidsilva Nov 13 '15
random comment.
you say "property worth nothing" in the template section, did you mean worth noting?
2
2
2
u/antoninj Nov 13 '15
That's really awesome. I can't wait to see the release. I've been playing around with Angular 2 and absolutely love it but I'm stuck on Angular 1.4 at work.
1
u/xCavemanNinjax Nov 14 '15
The template property can be defined as a function that is now injected with $element and $attrs locals. If the template property is a function then it needs to return an String representing the HTML to compile:
This reminds me of a react component with props and a render function.
1
u/vivainio Nov 14 '15
My earlier question was downvoted to oblivion for unknown reasons, so making a new post:
Has anyone tried using this new API with ES6 class syntax yet? Clearly, using just the plain ES5 api is not a problem either (i.e. have your controller as a class and 'component' declaration as a function), but it would be interesting to see if you can get some extra goodies from ES6 classes.
-8
4
u/chazzlabs Nov 13 '15
Why is transclusion enabled by default? If I'm creating a component with the default settings but not leveraging transclusion is there a small, unnecessary overhead cost there? We rarely use transclusion in our directives so the fact that it's enabled by default has me curious whether we're designing our directives correctly/optimally.
Great article overall though. I'm excited to use Component. We've been keeping on top of upgrading with each minor release, and so far it's been a breeze.