Running AngularJS 1.4.0-rc.1 the value within a ng-options
loop contains the type of the variable.
See the following code:
<script src=https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.1/angular.js>
</script>
<script>
angular.module(selectOptionsTest, []).
controller(SelectOptionsController, [$scope, function($scope) {
$scope.options = [
{id: 1, label: Item 1},
{id: 2, label: Item 2},
{id: 3, label: Item 3}
];
}]);
</script>
<div ng-app=selectOptionsTest ng-controller=SelectOptionsController>
<select ng-model=opt ng-options=option.id as option.label for option in options>
</select>
</div>
This generates HTML code which looks like this:
<select ng-options=option.id as option.label for option in options ng-model=option class=ng-pristine ng-valid ng-touched>
<option value=? selected=selected></option>
<option value=number:1 label=Item 1>Item 1</option>
<option value=number:2 label=Item 2>Item 2</option>
<option value=number:3 label=Item 3>Item 3</option>
</select>
Why is the value prefixed by the type of the variable, i.e. number:
? In previous versions of AngularJS (e.g. the current stable 1.3.15) the value
attributes are filled with the expected values of 1
, 2
and 3
.
So is this a bug in 1.4.0-rc.1 or do those cases need to be handled differently now?