aboutsummaryrefslogtreecommitdiffstats
path: root/src/service/controller.js
diff options
context:
space:
mode:
authorMisko Hevery2012-01-27 16:18:16 -0800
committerMisko Hevery2012-02-21 22:46:00 -0800
commit78656fe0dfc99c341ce02d71e7006e9c05b1fe3f (patch)
treea68731c4c1675047da65b23ccf3d562324324081 /src/service/controller.js
parentcb10ccc44fa78b82c80afa1cb5dac2c34fdf24b7 (diff)
downloadangular.js-78656fe0dfc99c341ce02d71e7006e9c05b1fe3f.tar.bz2
feat($compile) add locals, isolate scope, transclusion
Diffstat (limited to 'src/service/controller.js')
-rw-r--r--src/service/controller.js17
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);
};
}];
}