aboutsummaryrefslogtreecommitdiffstats
path: root/src/service/controller.js
blob: 22fb3b0252603be39c2b73d53afc912d839dc2a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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});
    };
  }];
}