Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($controller): remove the option to instantiate controllers from c… #15762

Merged
merged 2 commits into from Mar 1, 2017

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Feb 28, 2017

…onstructors on window

This also removes the likewise deprecated $controllerProvider.allowGlobals() method.

Closes #15349

BREAKING CHANGE:

The option to instantiate controllers from constructors on the global window object
has been removed. Likewise, the deprecated $controllerProvider.allowGlobals()
method that could enable this behavior, has been removed.

This behavior had been deprecated since AngularJS v1.3.0, because polluting the global scope
is bad. To migrate, remove the call to $controllerProvider.allowGlobals() in the config, and
register your controller via the Module API or the $controllerProvider, e.g.

angular.module('myModule', []).controller('myController', function() {...});

angular.module('myModule', []).config(function($controllerProvider) {
  $controllerProvider.register('myController', function() {...});
});

…onstructors on `window`

This also removes the likewise deprecated `$controllerProvider.allowGlobals()` method.

Closes angular#15349

BREAKING CHANGE:

The option to instantiate controllers from constructors on the global `window` object
has been removed. Likewise, the deprecated `$controllerProvider.allowGlobals()`
method that could enable this behavior, has been removed.

This behavior had been deprecated since AngularJS v1.3.0, because polluting the global scope
is bad. To migrate, remove the call to $controllerProvider.allowGlobals() in the config, and
register your controller via the Module API or the $controllerProvider, e.g.

```
angular.module('myModule', []).controller('myController', function() {...});

angular.module('myModule', []).config(function($controllerProvider) {
  $controllerProvider.register('myController', function() {...});
});

```
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a section in the phonecat tutorial that refers to global controllers. It is not exactly clear what it refers to (does it refer to allowGlobals or a hypothetical non-AngularJS app that defines controllers as globals), but it is weird enough and maybe could be removed along with allowGlobals().

Either way LGTM (as long as Travis si happy).

@Narretz
Copy link
Contributor Author

Narretz commented Mar 1, 2017

Thanks for the reviews - also feel free to re-start stalled Travis tests ;)

We should probably remove the section about global controllers from the tutorial.

@Narretz
Copy link
Contributor Author

Narretz commented Mar 1, 2017

I've removed the section about global controllers from the tutorial, PTAL

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removed tutorial section was also using manual construction that bypasses the DI so it was really bad anyway.

@Narretz Narretz merged commit e269c14 into angular:master Mar 1, 2017
@Narretz Narretz deleted the fix-remove-controller-global branch March 1, 2017 12:27
ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
This also removes the likewise deprecated `$controllerProvider.allowGlobals()` method.

Closes angular#15349
Closes angular#15762

BREAKING CHANGE:

The option to instantiate controllers from constructors on the global `window` object
has been removed. Likewise, the deprecated `$controllerProvider.allowGlobals()`
method that could enable this behavior, has been removed.

This behavior had been deprecated since AngularJS v1.3.0, because polluting the global scope
is bad. To migrate, remove the call to $controllerProvider.allowGlobals() in the config, and
register your controller via the Module API or the $controllerProvider, e.g.

```
angular.module('myModule', []).controller('myController', function() {...});

angular.module('myModule', []).config(function($controllerProvider) {
  $controllerProvider.register('myController', function() {...});
});

```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants