Skip to content

Commit bf74c72

Browse files
fix(ngOptions): iterate over the options collection in the same way as ngRepeat
In `ngRepeat` if the object to be iterated over is "array-like" then it only iterates over the numerical indexes rather than every key on the object. This prevents "helper" methods from being included in the rendered collection. This commit changes `ngOptions` to iterate in the same way. BREAKING CHANGE: Although it is unlikely that anyone is using it in this way, this change does change the behaviour of `ngOptions` in the following case: * you are iterating over an array-like object, using the array form of the `ngOptions` syntax (`item.label for item in items`) and that object contains non-numeric property keys. In this case these properties with non-numeric keys will be ignored. ** Here array-like is defined by the result of a call to this internal function: https://github.com/angular/angular.js/blob/v1.4.0-rc.1/src/Angular.js#L198-L211 ** To get the desired behaviour you need to iterate using the object form of the `ngOptions` syntax (`value.label` for (key, value) in items)`). Closes angular#11733
1 parent 77fcfb3 commit bf74c72

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/ng/directive/ngOptions.js

-4
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,6 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
344344

345345
for (var index = 0; index < optionValuesLength; index++) {
346346
var key = (optionValues === optionValuesKeys) ? index : optionValuesKeys[index];
347-
348-
// Ignore "angular" properties that start with $ or $$
349-
if (key.charAt && key.charAt(0) === '$') return;
350-
351347
var value = optionValues[key];
352348
var locals = getLocals(value, key);
353349
var viewValue = viewValueFn(scope, locals);

0 commit comments

Comments
 (0)