V
V
Vyacheslav Lebedev2015-10-10 04:24:25
Angular
Vyacheslav Lebedev, 2015-10-10 04:24:25

How to remove extra option from select?

Good day!
I don't understand why this option appears.
I create:

<select ng-model="limit">
  <option value="5" ng-selected="true">5</option>
  <option value="10">10</option>
  <option value="15">15</option>
</select>

In controller:
$scope.limit = 5
I get:
<select ng-model="limit" class="ng-pristine ng-valid ng-touched">
  <option value="? number:5 ?"></option>
  <option value="5" ng-selected="true" selected="selected">5</option>
  <option value="10">10</option>
  <option value="15">15</option> 
</select>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2015-10-11
@slavikse

Try this with ng-options

<div ng-app>
  <div ng-controller="TodoCtrl">
   <select ng-options="value for value in limits" ng-model="limit">
</select><br/>
  </div>
</div>

and the controller itself is like this.
function TodoCtrl($scope) {
     $scope.limits = [1,2,3,4,5];
     $scope.limit = 3
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question