At angular we have a service called $http
. I know that to call it just pass as a parameter of a closure, that the angular makes the magic:
angular.module('foo').controller(function ($http) {
/** ... **/
});
What if I want to use $http
out of controller
or config
? How?
Is there a way to use an angular service other than by injecting dependencies into function parameters?
For example:
var $http = ...; // pego a instância do serviço aqui...
$http.get('/pagina-do-site').then(function () {
})