Answer the question
In order to leave comments, you need to log in
Angularjs communication between directives, method call?
Hello everyone, please tell me, there are two directives, each has a controller that has its own methods. Directives not nested within each other. Just following each other. What method can be used from the controller of one directive to call the method of another directive? Pass method to be called in scope? What is the method to do this? Perhaps there is an article to read? Specify the direction where to dig. Thanks for answers.
Answer the question
In order to leave comments, you need to log in
three different ways
1) send a $broadcast event, catch it $on in the directive and call the desired function
2) embed an object with a function pointer through the attribute (bindings, '<', '='), var commander = { func: finction() {} }, inside the directive redefine the function commander.func = function () { here is my code... }, and call it from outside or in another directive commander.func();
3) it is better to place the code of the directive method, separately in the service, and call the service method in another directive, if the situation allows, and always design the application this way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question