All the documentation, examples and tutorials I've found on $resource
were using it directly in the controller. So far I'm just using $http
from services and those services are further used in the controllers. I thought $resource
should replace $http
and not my whole service. Is my thinking wrong, or were the examples I've found just so trivial that nobody bothered creating a service?
I've heard once the quote
When you want to create a command line interface for your application and you need to copy code out of the controller, than the controller has too much logic and it should be in a service.
Now, obviously this depends on the complexity of a controller, let's assume a simple CRUD view with the corresponding controller. It seems like $resource
would be all I need and I can take it also to create a console application without caring about anything else from the controller. But something inside me is just shouting when I want to access the data ($resource
) directly in the controller.
Where is the line to be drawn between when a service is necessary when it's overkill?