diff options
| author | Vojta Jina | 2012-01-20 14:04:53 -0800 |
|---|---|---|
| committer | Vojta Jina | 2012-01-23 13:11:12 -0800 |
| commit | dbffbefb7cd7af2ac063c95378a035aa9fbbd2ff (patch) | |
| tree | 047f7ae83c0573e1f1c22c44cba7644a1ab464b1 /src/service/controller.js | |
| parent | 0196411dbe179afe24f4faa6d6503ff3f69472da (diff) | |
| download | angular.js-dbffbefb7cd7af2ac063c95378a035aa9fbbd2ff.tar.bz2 | |
refactor($controller): Add $controller service for instantiating controllers
So that we can allow user to override this service and use BC hack:
https://gist.github.com/1649788
Diffstat (limited to 'src/service/controller.js')
| -rw-r--r-- | src/service/controller.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/service/controller.js b/src/service/controller.js new file mode 100644 index 00000000..22fb3b02 --- /dev/null +++ b/src/service/controller.js @@ -0,0 +1,26 @@ +'use strict'; + +function $ControllerProvider() { + this.$get = ['$injector', function($injector) { + + /** + * @ngdoc function + * @name angular.module.ng.$controller + * @requires $injector + * + * @param {Function} Class Constructor function of a controller to instantiate. + * @param {Object} scope Related scope. + * @return {Object} Instance of given controller. + * + * @description + * `$controller` service is responsible for instantiating controllers. + * + * It's just simple call to {@link angular.module.AUTO.$injector $injector}, but extracted into + * 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}); + }; + }]; +} |
