Skip to content

Commit a69251a

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

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,23 @@ 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+
In Angular 1.3.x, 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+
In Angular 1.4.x, the 'unknown option' will be selected. To remedy this, you can either initialize
1227+
the model as a string - `scope.x = '200'` - or implement a parser on `ngModel` that converts
1228+
the option string value to a `Number`.
12131229

12141230
<a name="1.3.9"></a>
12151231
# 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+
the `select` directive will now use strict comparison of the `ngModel` scope value against `option`
197+
values to determine which option is selected. This means `Number` scope values will not be matched
198+
against numeric option strings.
199+
In Angular 1.3.x, setting `scope.x = 200` would select the option with the value 200 in the following `select`:
200+
201+
```
202+
<select ng-model="x">
203+
<option value="100">100</option>
204+
<option value="200">200</option>
205+
</select>
206+
```
207+
208+
In Angular 1.4.x, the 'unknown option' will be selected. To remedy this, you can either initialize
209+
the model as a string - `scope.x = '200'` - or implement a parser on `ngModel` that converts
210+
the option string value to a `Number`.
211+
193212
## Templating (`ngRepeat`, `$compile`)
194213

195214
### ngRepeat

0 commit comments

Comments
 (0)