0

I am new to angular and want to know if I can inject controller into service and then that service can be shared into multiple services.

Or help me out to know how can I create a function in service which can be used my multiple controllers?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
chetank
  • 392
  • 3
  • 17
  • 2
    Just asking, why on earth would you inject a controller to a service? However you would need to inject [`$controller`](https://docs.angularjs.org/api/ng/service/$controller) service and instantiate the controller inside the service. – PSL Jun 05 '15 at 19:02
  • thanks @PSL. I know i am doing it wrong but i dont have time to refactor the code and use it. so for now the shortest path algorithm :) – chetank Jun 05 '15 at 19:04
  • haha. ok. But i'd suggest you to definitely revisit it and refactor. It is a part of a design problem you have... Here is an [answer which suggests](http://stackoverflow.com/questions/25417162/how-do-i-inject-a-controller-into-another-controller-in-angularjs/25417210#25417210) how to inject. – PSL Jun 05 '15 at 19:05
  • well thanks again @PSL. if you can make that an answer i can accept it if you want. – chetank Jun 05 '15 at 19:10

0 Answers0