简体   繁体   中英

My ng-option select bar is showing the last value in the list

Here is my HTML

<select ng-if="list[$index].length>0" data-ng-model="form1value[$index]"
        data-ng-options="label for label in obj.child track by $index">
</select>

I am getting the last value in obj.child as selected by default. I want to write 'select' in the select bar

You can use the following approach (--Select-- will be the default selected option):

<select ng-if="list[$index].length>0"  data-ng-model="form1value[$index]">
    <option value="">--Select--</option>
    <option ng-repeat="item in obj.child track by $index" value="{{item}}">{{item}}</option>
</select>

0" data-ng-model="form1value[$index]" ng-options="item.value as item.name in obj.child" class="form-control">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM