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

Commit 1bf1a62

Browse files
committed
docs(migration): in 1.3, global controllers are disabled by default
Closes #10775
1 parent b7117af commit 1bf1a62

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Diff for: docs/content/guide/migration.ngdoc

+38
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,44 @@ which drives many of these changes.
1515

1616
# Migrating from 1.2 to 1.3
1717

18+
## Controllers
19+
20+
Due to [3f2232b5](https://github.com/angular/angular.js/commit/3f2232b5a181512fac23775b1df4a6ebda67d018),
21+
`$controller` will no longer look for controllers on `window`.
22+
The old behavior of looking on `window` for controllers was originally intended
23+
for use in examples, demos, and toy apps. We found that allowing global controller
24+
functions encouraged poor practices, so we resolved to disable this behavior by
25+
default.
26+
27+
To migrate, register your controllers with modules rather than exposing them
28+
as globals:
29+
30+
Before:
31+
32+
```javascript
33+
function MyController() {
34+
// ...
35+
}
36+
```
37+
38+
After:
39+
40+
```javascript
41+
angular.module('myApp', []).controller('MyController', [function() {
42+
// ...
43+
}]);
44+
```
45+
46+
Although it's not recommended, you can re-enable the old behavior like this:
47+
48+
```javascript
49+
angular.module('myModule').config(['$controllerProvider', function($controllerProvider) {
50+
// this option might be handy for migrating old apps, but please don't use it
51+
// in new ones!
52+
$controllerProvider.allowGlobals();
53+
}]);
54+
```
55+
1856
## Angular Expression Parsing (`$parse` + `$interpolate`)
1957

2058
- due to [77ada4c8](https://github.com/angular/angular.js/commit/77ada4c82d6b8fc6d977c26f3cdb48c2f5fbe5a5),

0 commit comments

Comments
 (0)