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

Commit aff74ec

Browse files
committed
docs(changelog, migration): add BC notice for ngMessages evaluation
Introduced by Closes #11616 Closes #12001
1 parent 077ee37 commit aff74ec

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

CHANGELOG.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,6 @@ mechanism.
15441544

15451545
- **ngMessages:** due to [c9a4421f](https://github.com/angular/angular.js/commit/c9a4421fc3c97448527eadef1f42eb2f487ec2e0),
15461546

1547-
15481547
The `ngMessagesInclude` attribute is now its own directive and that must
15491548
be placed as a **child** element within the element with the ngMessages
15501549
directive. (Keep in mind that the former behaviour of the
@@ -1567,6 +1566,26 @@ end of the container containing the ngMessages directive).
15671566
</div>
15681567
```
15691568

1569+
- **ngMessages:** due to [c9a4421f](https://github.com/angular/angular.js/commit/c9a4421fc3c97448527eadef1f42eb2f487ec2e0),
1570+
1571+
it is no longer possible to use interpolation inside the `ngMessages` attribute expression. This technique
1572+
is generally not recommended, and can easily break when a directive implementation changes. In cases
1573+
where a simple expression is not possible, you can delegate accessing the object to a function:
1574+
1575+
```html
1576+
<div ng-messages="ctrl.form['field_{{$index}}'].$error">...</div>
1577+
```
1578+
would become
1579+
```html
1580+
<div ng-messages="ctrl.getMessages($index)">...</div>
1581+
```
1582+
where `ctrl.getMessages()`
1583+
```javascript
1584+
ctrl.getMessages = function($index) {
1585+
return ctrl.form['field_' + $index].$error;
1586+
}
1587+
```
1588+
15701589
- **$http:** due to [5da1256](https://github.com/angular/angular.js/commit/5da1256fc2812d5b28fb0af0de81256054856369),
15711590

15721591
`transformRequest` functions can no longer modify request headers.

docs/content/guide/migration.ngdoc

+19
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,25 @@ other inline messages situated as children within the `ngMessages` container dir
170170
Depending on where the `ngMessagesInclude` directive is placed it will be prioritized inline with the other messages
171171
before and after it.
172172

173+
Also due to [c9a4421f](https://github.com/angular/angular.js/commit/c9a4421fc3c97448527eadef1f42eb2f487ec2e0),
174+
it is no longer possible to use interpolation inside the `ngMessages` attribute expression. This technique
175+
is generally not recommended, and can easily break when a directive implementation changes. In cases
176+
where a simple expression is not possible, you can delegate accessing the object to a function:
177+
178+
```html
179+
<div ng-messages="ctrl.form['field_{{$index}}'].$error">...</div>
180+
```
181+
would become
182+
```html
183+
<div ng-messages="ctrl.getMessages($index)">...</div>
184+
```
185+
where `ctrl.getMessages()`
186+
```javascript
187+
ctrl.getMessages = function($index) {
188+
return ctrl.form['field_' + $index].$error;
189+
}
190+
```
191+
173192
### ngOptions
174193

175194
The `ngOptions` directive has also been refactored and as a result some long-standing bugs

0 commit comments

Comments
 (0)