Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Few days I've been trying to solve it using a function of a controller in another.

I have to get is that when you press a button click go away to another part of the application but with an open form. I have a function that opens the form in your controller working perfectly but I need to invoke that function from another part of the application for this (or it might please him happens to someone other way).

I hope you can help me I do not know what else to give ...

Greetings and thanks.

share|improve this question
1  
i think you used the service that used anywhere in program . – Anurag Pandey 19 hours ago

Move the function inside a factory. You can inject this factory in any controller to access the function.

controller('controller1', function(sharedFunctions){
   sharedFunctions.function1();
})

controller('controller2', function(sharedFunctions){
   sharedFunctions.function1();
})

factory('sharedFunctions', function(){

   return {
      function1: function() {
         console.log('function1 called')' 
      }    
   }
})
share|improve this answer

Bad answer: you can do this if the scope of your controller is child of the other controller (the one with the function to call). I believe this is not your case.

Better answer: you should move this function to a service, so that you can reuse it and call it from anyother place of your application. If the function is well written (loose coupled) it should be easy to do this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.