2

I have the following situation:

I have my app (module "zmApp") which has a directive, "myDirective" I am also using a 3rd party angular directive, lets call it "thirdPartyDirective", which is defined under "thirdPartyModule" by that author.

What I now want to do is share some data between 'myDirective' which is part of "zmApp" and "thirdPartyDirective" which is defined under "thirdPartyModule"

I tried creating a factory in zmApp and injecting it into "thirdPartyDirective", but that throws an error "Reference not found". I suspect its because they are two different modules.

I know directives can also have controllers, but my guess is if factories did not work nor will controllers.

How do I solve this predicament?

Many thanks

user1361529
  • 2,667
  • 29
  • 61
  • Share between the isolate scopes – ajmajmajma Jul 29 '15 at 19:52
  • 1
    You can share data between directives with a service/factory. If it wasn't working you would get an `Error: $injector:unpr Unknown Provider` not an error saying "Reference not found" – m0meni Jul 29 '15 at 19:55
  • 1
    http://stackoverflow.com/questions/27720707/how-to-communicate-between-controllers-of-two-different-modules-in-angularjs/27721056#27721056 take a look at this. It is communication between two controllers in separate modules. Same concept applies. – Martin Jul 29 '15 at 19:59
  • @AR7, you are absolutely correct. I was pulling my hair out on this - as it turned out, i injected it into one directive and was using from another directive in the same file without knowing it was part of another directive. I don't see any way to accept a comment, so I upvoted it. – user1361529 Jul 29 '15 at 20:40
  • @user1361529 lol just like your avatar. Glad I could help – m0meni Jul 29 '15 at 20:42

0 Answers0