Skip to content

Commit c9dee46

Browse files
committed
docs(select): add note about breaking change with numeric values
Closes angular#12052
1 parent 1fda280 commit c9dee46

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,22 @@ But in practice this is not what people want and so this change iterates over pr
12091209
in the order they are returned by Object.keys(obj), which is almost always the order
12101210
in which the properties were defined.
12111211

1212+
- **select:** due to [7fda214c](https://github.com/angular/angular.js/commit/7fda214c4f65a6a06b25cf5d5aff013a364e9cef),
12121213

1214+
the `select` directive will now use strict comparison of the `ngModel` scope value against `option`
1215+
values to determine which option is selected. This means `Number` scope values will not be matched
1216+
against numeric option strings.
1217+
Previously, setting `scope.x = 200` would select the `option` with the value 200 in the following `select`:
1218+
1219+
```
1220+
<select ng-model="x">
1221+
<option value="100">100</option>
1222+
<option value="200">200</option>
1223+
</select>
1224+
```
1225+
1226+
To remedy this, you can either initialize the model as a string - `scope.x = '200'` - or implement a
1227+
parser on `ngModel` that converts the `option` string value to a `Number`.
12131228

12141229
<a name="1.3.9"></a>
12151230
# 1.3.9 multidimensional-awareness (2015-01-13)

docs/content/guide/migration.ngdoc

+20-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class based animations (animations triggered via ngClass) in order to ensure tha
136136

137137

138138

139-
## Forms (`ngMessages`, `ngOptions`)
139+
## Forms (`ngMessages`, `ngOptions`, `select`)
140140

141141
### ngMessages
142142
The ngMessages module has also been subject to an internal refactor to allow it to be more flexible
@@ -190,6 +190,25 @@ in the order they are returned by Object.keys(obj), which is almost always the o
190190
in which the properties were defined.
191191

192192

193+
### select
194+
195+
Due to [7fda214c](https://github.com/angular/angular.js/commit/7fda214c4f65a6a06b25cf5d5aff013a364e9cef),
196+
197+
the `select` directive will now use strict comparison of the `ngModel` scope value against `option`
198+
values to determine which option is selected. This means `Number` scope values will not be matched
199+
against numeric option strings.
200+
Previously, setting `scope.x = 200` would select the `option` with the value 200 in the following `select`:
201+
202+
```
203+
<select ng-model="x">
204+
<option value="100">100</option>
205+
<option value="200">200</option>
206+
</select>
207+
```
208+
209+
To remedy this, you can either initialize the model as a string - `scope.x = '200'` - or implement a
210+
parser on `ngModel` that converts the `option` string value to a `Number`.
211+
193212
## Templating (`ngRepeat`, `$compile`)
194213

195214
### ngRepeat

0 commit comments

Comments
 (0)