View source Improve this doc

$controller

service in module ng

Description

$controller service is responsible for instantiating controllers.

It's just a simple call to $injector, but extracted into a service, so that one can override this service with BC version.

Dependencies

  • $injector

Usage

  1. $controller(constructor, locals);

Parameters

ParamTypeDetails
constructorFunctionstring If called with a function then it's considered to be the controller constructor function. Otherwise it's considered to be a string which is used to retrieve the controller constructor using the following steps: - check if a controller with given name is registered via $controllerProvider - check if evaluating the string on the current scope returns a constructor - check window[constructor] on the global window object
localsObject Injection locals for Controller.

Returns

Object Instance of given controller.