search

Home  >  Q&A  >  body text

Can angularJS modules communicate with each other?

There are two ng-app app1 and app2. Can parameters be passed between them?

三叔三叔2737 days ago923

reply all(2)I'll reply

  • 仅有的幸福

    仅有的幸福2017-06-22 11:55:20

    Provide an idea to directly bind a global variable or data structure, and then both apps can access it, which can realize the value transfer function,

    reply
    0
  • 三叔

    三叔2017-06-22 11:55:20

    You definitely have this problem, and there are many ways to solve it. The idea is as follows:
    1. Use the service of the module to provide public services, and both modules reference the service at the same time
    2. Use the module factory, the same as above
    3. In addition, define an app3, so that both of your apps depend on this app3 (I really can’t think of it One of the methods)
    4. Use the event delivery method $emit (the second method that is really unexpected)

    reply
    0
  • Cancelreply