Hi folks! I'm a bit confused in the last few days about a situation with controllers and directives. Here's my case:
1. I have a custom directive called "commentList" that shows a list of comments (duh) for a given entity and entityId (let's say, a product and productId). This directive has a CommentListController, that will fetch the list from a CommentService, and watch the scope for entity id/type changes. The directive can be placed anywhere alone. 2. I have a custom directive called "commentForm" that shows a textarea + a "submit" button, to save the comment. This directive has a CommentFormController, that will send the comment to the CommentService for persistence. This directive also relates to an entityId/type, and can be placed anywhere alone. 3. I want to write a third directive, to wrap the other two, with an isolated scope and a controller, to act as a mediator between then, so when the form is sent, the list is updated. Now the question is: how should I configure this third directive to find the controllers of the child elements (list and form) instead of looking upward, like in "^commentList". I know that the form could trigger an event when a comment is added, and the list could listen for a "new-comment" event, but it would break the list encapsulation, since it would know about external environmental stuff. The mediator should call the list instead, right? I could also listen to events inside the CommentService, as it is lower in the hierarchy, but how should I implement this? Just using a custom event emitter or using AngularJS mechanism?. I hope the explanation is clear enough. Thanks in advance for any help, Darlan. -- 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/groups/opt_out.
<<attachment: angular-issue.png>>
