From 78656fe0dfc99c341ce02d71e7006e9c05b1fe3f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 27 Jan 2012 16:18:16 -0800 Subject: feat($compile) add locals, isolate scope, transclusion --- src/service/controller.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/service/controller.js') 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); }; }]; } -- cgit v1.2.3