Thanks, I found it very helpful!
Sorry, link to the latest version http://jsfiddle.net/eshepelyuk/vhKfq/
Середа, 30 травня 2012 р. 23:18:58 UTC+3 користувач Lukas Ruebbelke написав:
Lukas,Thanks for the video.You and I discussed this offline and I thought I woud post for the AngularJS community.Use $scope to message [using $emit() or $broadcast()] across controllers works only for Controllers. Using a sharedService may be too heavyweight.Better yet would be the use of a Publish/Subscribe mechanism [aka MessageQueue]. I created a MessageQueue mechanism that is published like an EventDispatcher.So any object can have the EventDispatcher inject and use that to listen to all publishers or dispatch/announce on that queue [event type],I have decided to blog/screencast about Publish/Subscribe and EventDispatcher solutions in AngularJS.Meanwhile, here is a revised jsFiddlehttp://jsfiddle.net/ThomasBurleson/sv7D5/.The AngularJS app MessagingDemo uses injected EventDispatchers instances to create specific publish/subscribe message queues.
- Notice that the app also uses a reusable Angular.module called `messaging`.
- Notice how the MessagingDemo requires the `messaging` module: angular.module('MessagingDemo', ['messaging']);
For Flex developers the EventDispatcher approach will seem very familiar.And I think the Publish/Subscribe service code [used within the above jsFiddle] is very valuable for AngularJS developers: MessagingService.js.- ThomasB