@@ -13,6 +13,156 @@ which drives many of these changes.
13
13
* Several new features, especially animations, would not be possible without a few changes.
14
14
* Finally, some outstanding bugs were best fixed by changing an existing API.
15
15
16
+
17
+
18
+
19
+
20
+ # Migrate from 1.4 to 1.5
21
+
22
+ Angular 1.5 takes a big step towards preparing developers for a smoother transition to Angular 2 in
23
+ the future. Architecturing your applications using components, making use of lifecycle hooks in
24
+ directive controllers and relying on native ES6 features (such as classes and arrow functions) are
25
+ now all possible with Angular 1.5.
26
+
27
+
28
+ This release includes numerous bug and security fixes, as well as performance improvements to core
29
+ services, directives, filters and helper functions. Existing applications can start enjoying the
30
+ benefits of such changes in `$compile`, `$parse`, `$animate`, `$animateCss`, `$sanitize`, `ngOptions`,
31
+ `currencyFilter`, `numberFilter`, `copy()` (to name but a few) without any change in code.
32
+
33
+ New features have been added to more than a dozen services, directives and filters across 7 modules.
34
+ Among them, a few stand out:
35
+
36
+ * `angular.component()`: Introducing "components", a special sort of directive that are easy to
37
+ configure and promote best practices (plus can bring Angular 1 applications closer to Angular 2's
38
+ style of architecture).
39
+ * Multi-slot transclusion: Enabling the design of more powerful and complex UI elements with a much
40
+ simpler configuration and reduced boilerplate.
41
+ * `ngAnimateSwap`: A new directive in `ngAnimate`, making it super easy to create rotating
42
+ banner-like components
43
+ * Testing helpers: New helper functions in `ngMock`, simplifying testing for animations, component
44
+ controllers and routing.
45
+
46
+ Also, notable is the improved support for ES6 features, such as classes and arrow functions. These
47
+ features are now more reliably detected and correctly handled within the core.
48
+
49
+
50
+ All this goodness doesn't come without a price, though. Below is a list of breaking changes (grouped
51
+ by module) that need to be taken into account while migrating from 1.4. Fortunately, the majority of
52
+ them should have a pretty low impact on most applications.
53
+
54
+
55
+ ## Core
56
+
57
+ We tried to keep the breaking changes inside the core components to a bare minimum. Still, a few of
58
+ them were unavoidable.
59
+
60
+ ### Services (`$parse`)
61
+
62
+ Due to [0ea53503](https://github.com/angular/angular.js/commit/0ea535035a3a1a992948490c3533bffb83235052),
63
+ a new special property, `$locals`, will be available for accessing the locals from an expression.
64
+ This is a breaking change, only if a `$locals` property does already exist (and needs to be
65
+ referenced) either on the `scope` or on the `locals` object. Your expressions should be changed to
66
+ access such existing properties as `this.$locals` and `$locals.$locals` respectively.
67
+
68
+
69
+ ### Directives (`ngOptions`)
70
+
71
+ A fair amount of work has been put into the `ngOptions` directive, fixing bugs and corner-cases and
72
+ neutralizing browser quirks. A couple of breaking changes were made in the process:
73
+
74
+ Due to [b71d7c3f](https://github.com/angular/angular.js/commit/b71d7c3f3c04e65b02d88b33c22dd90ae3cdfc27),
75
+ falsy values (`''`, `0`, `false` and `null`) are properly recognized as option group identifiers for
76
+ options passed to `ngOptions`. Previously, all of these values were ignored and the option was not
77
+ assigned to any group. `undefined` is still interpreted as "no group".
78
+ If you have options with falsy group indentifiers that should still not be assigned to any group,
79
+ then you must filter the values before passing them to `ngOptions`, converting falsy values to
80
+ `undefined`.
81
+
82
+ Due to [ded25187](https://github.com/angular/angular.js/commit/ded2518756d4409fdfda0d4af243f2125bea01b5),
83
+ `ngOptions` now explicitly requires `ngModel` on the same element, thus an error will be thrown if
84
+ `ngModel` is not found. Previously, `ngOptions` would silently fail, which could lead to
85
+ hard-to-debug errors.
86
+ This is not expected to have any significant impact on applications, since `ngOptions` didn't work
87
+ without `ngModel` before either. The main difference is that now it will fail with a more
88
+ informative error message.
89
+
90
+
91
+ ### Filters (`orderBy`)
92
+
93
+ Due to [2a85a634](https://github.com/angular/angular.js/commit/2a85a634f86c84f15b411ce009a3515fca7ba580),
94
+ passing a non-array-like value (other than `undefined` or `null`) through the `orderBy` filter will
95
+ throw an error. Previously, the input was returned unchanged, which could lead to hard-to-spot bugs
96
+ and was not consistent with other filters (e.g. `filter`).
97
+ Objects considered array-like include: arrays, array subclasses, strings, NodeLists,
98
+ jqLite/jQuery collections
99
+
100
+
101
+ ## ngMessages (`ngMessage`)
102
+
103
+ Due to [4971ef12](https://github.com/angular/angular.js/commit/4971ef12d4c2c268cb8d26f90385dc96eba19db8),
104
+ the `ngMessage` directive is now compiled with a priority of 1, which means directives on the same
105
+ element as `ngMessage` with a priority lower than 1 will be applied when `ngMessage` calls its
106
+ `$transclude` function. Previously, they were applied during the initial compile phase and were
107
+ passed the comment element created by the transclusion of `ngMessage`.
108
+ If you have custom directives that relied on the previous behavior, you need to give them a priority
109
+ of 1 or greater.
110
+
111
+
112
+ ## ngResource (`$resource`)
113
+
114
+ The `$resource` service underwent a minor internal refactoring to finally solve a long-standing bug
115
+ preventing requests from being cancelled using promises. Due to the nature of `$resource`'s
116
+ configuration, it was not possible to follow the `$http` convention. A new `$cancelRequest()` method
117
+ was introduced instead.
118
+
119
+ Due to [98528be3](https://github.com/angular/angular.js/commit/98528be311b48269ba0e15ba4e3e2ad9b89693a9),
120
+ using a promise as `timeout` in `$resource` is no longer supported and will log a warning. This is
121
+ hardly expected to affect the behavior of your application, since a promise as `timeout` didn't work
122
+ before either, but it will now warn you explicitly when trying to pass one.
123
+ If you need to be able to cancel pending requests, you can now use the new `$cancelRequest()` that
124
+ will be available on `$resource` instances.
125
+
126
+
127
+ ## ngRoute (`ngView`)
128
+
129
+ Due to [983b0598](https://github.com/angular/angular.js/commit/983b0598121a8c5a3a51a30120e114d7e3085d4d),
130
+ a new property will be available on the scope of the route, allowing easy access to the route's
131
+ resolved values from the view's template. The default name for this property is `$resolve`. This is
132
+ a breaking change, only if a `$resolve` property is already available on the scope, in which case
133
+ the existing property will be hidden or overwritten.
134
+ To fix this, you should choose a custom name for this property, that does not collide with other
135
+ properties on the scope, by specifying the `resolveAs` property on the route.
136
+
137
+
138
+ ## ngSanitize (`$sanitize`, `linky`)
139
+
140
+ The HTML sanitizer has been re-implemented using inert documents, increasing security, fixing some
141
+ corner-cases that were difficult to handle and reducing its size by about 20% (in terms of loc). In
142
+ order to make it more secure by default, a couple of breaking changes have been introduced:
143
+
144
+ Due to [181fc567](https://github.com/angular/angular.js/commit/181fc567d873df065f1e84af7225deb70a8d2eb9),
145
+ SVG support in `$sanitize` is now an opt-in feature (i.e. disabled by default), as it could make
146
+ an application vulnerable to click-hijacking attacks. If your application relies on it, you can
147
+ still turn it on with `$sanitizeProvider.enableSvg(true)`, but you extra precautions need to be
148
+ taken in order to keep your application secure. Read the documentation for more information about
149
+ the dangers and ways to mitigate them.
150
+
151
+ Due to [7a668cdd](https://github.com/angular/angular.js/commit/7a668cdd7d08a7016883eb3c671cbcd586223ae8),
152
+ the `$sanitize` service will now remove instances of the `<use>` tag from the content passed to it.
153
+ This element is used to import external SVG resources, which is a security risk as the `$sanitize`
154
+ service does not have access to the resource in order to sanitize it.
155
+
156
+ Due to [98c2db7f](https://github.com/angular/angular.js/commit/98c2db7f9c2d078a408576e722407d518c7ee10a),
157
+ passing a non-string value (other than `undefined` or `null`) through the `linky` filter will throw
158
+ an error. This is not expected to have any significant impact on applications, since the input was
159
+ always assumed to be of type 'string', so passing non-string values never worked correctly anyway.
160
+ The main difference is that now it will fail faster and with a more informative error message.
161
+
162
+
163
+
164
+
165
+
16
166
# Migrating from 1.3 to 1.4
17
167
18
168
Angular 1.4 fixes major animation issues and introduces a new API for `ngCookies`. Further, there
0 commit comments