angular.injector
(API in module ng
)
Creates an injector function that can be used for retrieving services as well as for dependency injection (see dependency injection).
angular.injector(modules);
modules – {Array.<string|Function>} –
A list of module functions or their aliases. See
angular.module
. The ng
module must be explicitly added.
{function()}
– Injector function. See $injector
.
Typical usage
// create an injector var $injector = angular.injector(['ng']); // use the injector to kick off your application // use the type inference to auto inject arguments, or use implicit injection $injector.invoke(function($rootScope, $compile, $document){ $compile($document)($rootScope); $rootScope.$digest(); });