Skip to content Skip to sidebar Skip to footer

Using Angular Services Before Manual Bootstrap

I would like to use angular services before doing a manual bootstrap(the ng-app directive is not being used). Is there a way to access angular services without calling angular.boo

Solution 1:

There isn't a way to do it without calling bootstrap (or getting the injector from an already bootstrapped element), but there is a slightly more direct way of doing it:

var $http = angular.bootstrap().get('$http');

Or, if you need multiple services, you can do this:

angular.bootstrap().invoke(function($http, $location){ 
    $http.get('/foo');
    $location.path('/foo');
});

Post a Comment for "Using Angular Services Before Manual Bootstrap"