Imagine we have a service like this:
myApp.factory('FooService', function () { ...
Now, from a controller, the code would look something like this:
myApp.controller('FooCtrl', ['$scope', 'FooService', function ($scope, FooService) { ...
The burning question here is:
- Making Service Globally Accessible: Let's say I have numerous controllers and they all require access to this service. I don't want to manually inject it each time. How can I achieve global availability of the service? One option that comes to mind is wrapping it in the root scope, but that contradicts the original purpose.
- Accessing Service from View: How can I utilize the service directly from the view? This post suggests wrapping the service within the controller. If I'm going to that extent, wouldn't it be more efficient to just implement the functionality directly on the root scope?