Skip to content

Commit 4846404

Browse files
fix(ngOptions): ensure that the correct option is selected when options are loaded async
**Major reworking of select and ngOptions**: * The `SelectController` is now used as an abstraction for the `select` and `ngOptions` directives to override to get their desired behaviour * The `select` directive is completely oblivious to the ngOptions directive now - the `ngOptions` directive could be deleted without having to make any changes to the `select` directive. * Select related directives (single/multiple/ngOptions) can provide specific versions of `SelectController.writeValue` and `SelectController.readValue`, which are responsible for getting the `$viewValue` in or out of the actual `<select>` element and its `<option>` children. BREAKING CHANGE: Although it is internal, and not documented, this commit changes the actual strings that are stored as the value of each `<option>` element. We now store a string that is computed by calling `hashKey` on the item in the options collection; before it was the index or key value of the item in the collection. Before you might have seen: ``` <select ng-model="x" ng-option="i in items"> <option value="1">a</option> <option value="2">b</option> <option value="3">c</option> <option value="4">d</option> </select> ``` Now it will be something like: ``` <select ng-model="x" ng-option="i in items"> <option value="string:a">a</option> <option value="string:b">b</option> <option value="string:c">c</option> <option value="string:d">d</option> </select> ``` If your application code relied on this value, which it shouldn't, then you will need to modify your application to accommodate this. Closes angular#9714
1 parent a01ce6b commit 4846404

File tree

5 files changed

+2420
-2591
lines changed

5 files changed

+2420
-2591
lines changed

angularFiles.js

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var angularFiles = {
6565
'src/ng/directive/ngList.js',
6666
'src/ng/directive/ngModel.js',
6767
'src/ng/directive/ngNonBindable.js',
68+
'src/ng/directive/ngOptions.js',
6869
'src/ng/directive/ngPluralize.js',
6970
'src/ng/directive/ngRepeat.js',
7071
'src/ng/directive/ngShowHide.js',

0 commit comments

Comments
 (0)