forgottofly
forgottofly

Reputation: 2719

select dropdown not binding values

I need to bind by default the second value in my select drop down which I'm generating with a list of numbers from 0.01 to 10

                getComms();
                function getComms() {
                     $scope.numbersArray=[]
                    for (var j=1,i = 0.01; i <= 10; i += 0.01,j++) {

                        var newArray={
                            id:j,
                            value:i
                        }
                        $scope.numbersArray.push(newArray);

                    }
                }

Heres my select dropdown

  <select ng-model="test.info" class="form-control" ng-options="r.id as r.value for r  in numbersArray"  tabindex="1">
                    <option value="">--Select--</option>
                </select> 

Upvotes: 0

Views: 82

Answers (1)

mikegertrudes
mikegertrudes

Reputation: 653

In your controller, you will have to explicitly set your model equal to the second element in the array.

$scope.test.info = $scope.numbersArray[1];

Upvotes: 1

Related Questions