search

Home  >  Q&A  >  body text

javascript - Is it possible to call methods across controllers in Angular?

I want to use the controller in the page js to call a method in a controller in the bus js. Is this possible? $rootscope is not allowed to be added, and public js is not allowed to be changed. It is said that it is not allowed to be moved in the framework. .

扔个三星炸死你扔个三星炸死你2736 days ago814

reply all(3)I'll reply

  • 三叔

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

    The core of angular is service, but there is no need for service. Write common methods in the service and then call them via dependency injection.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-22 11:55:16

    You can talk about your specific functional scenario. There must be something wrong with the method you use.

    reply
    0
  • 黄舟

    黄舟2017-06-22 11:55:16

    You can register a service, write the method you want in it, and then inject the service into the controller and you can call it

    reply
    0
  • Cancelreply