View source Improve this doc

angular.injector
API in module ng

Description

Creates an injector function that can be used for retrieving services as well as for dependency injection (see dependency injection).

Usage

angular.injector(modules);

Parameters

ParamTypeDetails
modulesArray.<string|Function>

A list of module functions or their aliases. See angular.module. The ng module must be explicitly added.

Returns

function()

Injector function. See $injector.

Example

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();
  });