Skip to content

Commit 47735b9

Browse files
committed
use $injector instead of adding new code to angular.min.js angular#13683
1 parent c2270e1 commit 47735b9

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/ng/compile.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
928928
return this;
929929
};
930930

931-
this.$$componentControllers = createMap();
932931
/**
933932
* @ngdoc method
934933
* @name $compileProvider#component
@@ -1054,8 +1053,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10541053
*/
10551054
this.component = function registerComponent(name, options) {
10561055
var controller = options.controller || function() {};
1057-
var ident = identifierForController(options.controller) || options.controllerAs || '$ctrl';
1058-
this.$$componentControllers[name] = { controller: controller, ident: ident};
10591056

10601057
function factory($injector) {
10611058
function makeInjectable(fn) {
@@ -1071,7 +1068,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10711068
var template = (!options.template && !options.templateUrl ? '' : options.template);
10721069
return {
10731070
controller: controller,
1074-
controllerAs: ident,
1071+
controllerAs: identifierForController(options.controller) || options.controllerAs || '$ctrl',
10751072
template: makeInjectable(template),
10761073
templateUrl: makeInjectable(options.templateUrl),
10771074
transclude: options.transclude,

src/ngMock/angular-mocks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,10 +2180,10 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
21802180
*/
21812181
angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) {
21822182
return {
2183-
$get: ['$controller', function($controller) {
2183+
$get: ['$controller','$injector', function($controller,$injector) {
21842184
return function $componentController(componentName, locals, bindings, ident) {
2185-
var controllerInfo = $compileProvider.$$componentControllers[componentName];
2186-
return $controller(controllerInfo.controller, locals, bindings, ident || controllerInfo.ident);
2185+
var directiveInfo = $injector.get(componentName + 'Directive')[0];
2186+
return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs);
21872187
};
21882188
}]
21892189
};

0 commit comments

Comments
 (0)