Sunday, 15 February 2015

angularjs - Event propagation to siblings (exclude self/transmitter) -


I want to send an event to a sibling, with the exception of the sender of the event. I know that the target sender should be included, but as I am using the $ scope. $ Parent, I will not recognize where the event was sent (event.targetScope $ scope will be $ .parent).

$ scope of $ $ Parent $ Broadcast ('super event', data); $ Scope $ ('Superevent', Function (Event, Data) {// I do not want to do anything when sent from current $ scope});

Currently, I have a workaround by adding $ scope in the event data. I workaround:

  $ scope of $ $ Parent $ Broadcast ('supervant', data, $ area); $ Scope $ ('Superevent', function (event, data, sender scope) {if ($ scope === sender scope) {return; // skip} // do something with data}};  

There is no way to clearly send an event that does not include dispatch scope is. I think your solution is best solution (or some equivalent, such as scope of $ Id) is the best solution.


No comments:

Post a Comment