diff options
Diffstat (limited to 'src/service/controller.js')
| -rw-r--r-- | src/service/controller.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/service/controller.js b/src/service/controller.js index 22fb3b02..229ce14a 100644 --- a/src/service/controller.js +++ b/src/service/controller.js @@ -1,15 +1,16 @@ 'use strict'; function $ControllerProvider() { - this.$get = ['$injector', function($injector) { + this.$get = ['$injector', '$window', function($injector, $window) { /** * @ngdoc function * @name angular.module.ng.$controller * @requires $injector * - * @param {Function} Class Constructor function of a controller to instantiate. - * @param {Object} scope Related scope. + * @param {Function|string} Class Constructor function of a controller to instantiate, or + * expression to read from current scope or window. + * @param {Object} locals Injection locals for Controller. * @return {Object} Instance of given controller. * * @description @@ -19,8 +20,14 @@ function $ControllerProvider() { * a service, so that one can override this service with {@link https://gist.github.com/1649788 * BC version}. */ - return function(Class, scope) { - return $injector.instantiate(Class, {$scope: scope}); + return function(Class, locals) { + if(isString(Class)) { + var expression = Class; + Class = getter(locals.$scope, expression, true) || getter($window, expression, true); + assertArgFn(Class, expression); + } + + return $injector.instantiate(Class, locals); }; }]; } |
