Actually, the problem is the inverse- I have a directive from a third-party
library ( https://github.com/flowjs/ng-flow ), which handles events by
calling $scope.$broadcast on its scope. As I understand angular events,
this will only propagate down the scope chain, to the scopes inside the
third-party directive.

At least, I think that's how that works. If the library used $scope.$emit
instead, it would go up instead of down, and if it were app-wide, it'd be
$rootScope.$broadcast.

The problem is that I use this third-party directive in the template for a
directive I'm writing myself to bundle up media-upload functionality, and I
really want to receive those events on the parent scope to the third-party
directive. As i understand it, my only real choice here is to either change
my application structure (to put the third party directive higher in the
hierarchy) or to fork the library and change their event broadcasting code.
Does that make sense? Am I missing something?

e

On Mon, Sep 15, 2014 at 11:40 PM, Sander Elias <[email protected]>
wrote:

> Hi Eric,
>
> I’m not sure I get it, you need some events that needs to be broadcasting
> through your entire system? If that is true, inject rootScope, and use that.
> If you need it for just a specific part of your app, create a broadcast
> method on the top-level directive of that part.
> hmm, I just builded a small sample, the easiest is add an directtive that
> handles the local-casting, something like this:
>
>      function localCast() {
>         var ddo = {
>             restrict : 'A',
>             controllerAs : 'localCast',
>             controller : ['$scope', function (scope) {
>                 this.broadcast= function (name,args) {
>                     // Handling just 1 argument is my laziness ;)
>                     scope.$broadcast(name, args);
>                 };
>             } ]
>         };
>         return ddo;
>     }
>
> see it in action: http://plnkr.co/edit/N23XN4eqSWPBVpELpFon?p=preview
>
> how about that?
>
> 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.
>

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