I have a list that I create with select using AngularJS ng-repeat. The list will be created correctly, and when I select one of the elements and press the button, I will go to the function and will have the necessary information.
My html code is as follows:
<select size="6" ng-model="item" ng-options="s.name for s in itemlist"></select> <button class="btn tt-btn-blue" ng-model="singleModel" ng-click="onLoadClicked(item.id)">Load</button>
My problem is that when drawing a list, there is one element at the top that is empty. When I check the list at runtime in Chrome, I get the following output in the console:
<select size="6" ng-model="item" ng-options="s.name for s in itemlist" class="ng-pristine ng-valid"> <option value="?" selected="selected"></option> <option value="0">Item 1</option> <option value="1">Item 2</option> <option value="2">Item 3</option> <option value="3">Item 4</option> <option value="4">Item 5</option> <option value="5">Item 6</option> </select>
I am wondering how I can get rid of the first option inserted by ng-repeat. I do not want to see an empty space at the top of the list. I understand that one option would be to set the first actual parameter (value = "0") as the selected item, but I would prefer that there are no selected items to run.
javascript angularjs select
bmahf Mar 18 '13 at 22:28 2013-03-18 22:28
source share