Thanks for your input Eric. I will explain it a little further. Child
directive exposes common set of interfaces for communications. Lets say
that Child has an action "refresh". This child does not do anything by
itself. It acts as container for some other directive(s).

Parent
 - Child (1) {refresh}
   - DoFooDirective
   - DoBarDirective
 - Child (2) {refresh}
  - DoBazDirective

Lets say that DoFoo has done something. It needs to tell Child(2) that it
needs to refresh the directives that it is housing. That refresh means
different things to each of these directives.

I hope this explains the structure little better.


On Tue, Aug 26, 2014 at 11:52 AM, Eric Eslinger <[email protected]>
wrote:

> Each child directive has the same set of actions, but does stuff on
> different data? As in, they all have a doStuff() that manipulates their
> unique data, but the data they contain is different.
>
> In that case, this smells kind of like a situation where you'd want to
> have a more robust model layer. If the directives are presenting a view,
> you could put all the relevant data in a model that gets pushed into the
> view. <child ng-repeat="item in items" item="item">, and then define your
> functions on the item objects. Models could have an arbitrary relationship
> outside of the event doodad.
>
>
>
>
> On Tue, Aug 26, 2014 at 8:29 AM, Naveen Kohli <[email protected]>
> wrote:
>
>> I am trying to set up a framework that following structure.
>> Parent Container (It is a directive)
>>  - Child (Its a directive)
>>  - Child
>>  - Child
>>  .... so on
>>
>> Parent contains collection of same "Child" directive. Each child
>> directive can be identified by a unique id.
>>
>> Each instance of child directive performs unique actions. At some point
>> one child has to communicate with other child to do signal it to do
>> something in response to some action it has done.
>> There is one clean options I can see for this communication.
>> Use pub/sub model through a factory. Child can "emit" message to parent
>> and then parent "broadcasts" message with unique id of child that has to
>> take action.
>>
>> Is there some other better to handle this kind of scenario?
>>
>> No, I don't have plunker at the moment for this use case. I am just
>> putting some initial design in place.
>>
>> Thanks
>>
>> --
>> 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.
>>
>
>  --
> 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.
>



-- 
Naveen K Kohli
http://www.netomatix.com

-- 
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.

Reply via email to