This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,44 @@ which drives many of these changes.
15
15
16
16
# Migrating from 1.2 to 1.3
17
17
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
+
18
56
## Angular Expression Parsing (`$parse` + `$interpolate`)
19
57
20
58
- due to [77ada4c8](https://github.com/angular/angular.js/commit/77ada4c82d6b8fc6d977c26f3cdb48c2f5fbe5a5),
You can’t perform that action at this time.
0 commit comments