10

In an MVC framework, the data are handled in the model.

In AngularJs, is it common to handle the data directly in a controller, or should it be done in a service instead?

JMaylin
  • 1,358
  • 3
  • 15
  • 38

1 Answers1

6

There is no harm in firing XHRs from within a controller if controller is the only one using the call.

But if multiple controllers need to make the same call you would better move it inside a service for ease of access.

AlwaysALearner
  • 43,341
  • 9
  • 94
  • 78
  • This is what I do, I just wanted to know what purists think about it. Thank you for your answer. – JMaylin Sep 30 '13 at 07:48
  • u said move ajax call in service due to ease of access. why not to move the ajax call in factrory.....please tell me the reason why avoid factor for this purpose? – Monojit Sarkar Jun 12 '17 at 14:11