Hi Sergio, Ganaraj, Thanks for your input. However I reacted to an earlier question, the question itself was not mine! I made a small sample that shows a way, on how to expose an API (in the form of an directive-controller) to it's children, and even to the scope and controllers. The sample is about show how to do this, and its not following all best practices, and yes I'm aware of that.
Directives that need an api are for example, a breadcrumb, a tabgroup, a accordion, a toaster(popup) and so on. The use of events($on/$emit/$broadcast) is in a lot of cases also possible, but have the downside of needing an additional digest cycle, and have a brittle feeling to it in my opinion. And it becomes more complicated if you want to reuse the directive/service combo multiple times in a page (as an example, you can have more than one tabgroup/accordion in a single view!) Injecting a service is also possible, but If you want to use this in the view, you have to expose it to the scope also. This solution has also the same disadvantage when reusing components. Using the scope for sharing thing has also the same issue, and even a couple more. Of course this can be made to work, but it is a sure road to tight coupling and other maintenance headaches. Awaiting your reaction's with kind regards Sander -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
