简体   繁体   中英

how to bind the value properly to a angular dropdown

I thought I understood how to do this but my angular dropdown is not putting the value into my control as expected. I am getting value set to 0 when it should be 2005.

2015

// array
vm.years = [thisYear, thisYear - 1, thisYear - 2, thisYear - 3, thisYear - 4, thisYear - 5, thisYear - 6, thisYear - 7, thisYear - 8, thisYear - 9];

 <select name="row.endYear" data-ng-model="row.endYear" ng-options="I give up" class="form-control" id="endYear" required data-z-validate>
                    <option value="">End Year *</option>
                </select>

You need to populate the dropdown ng-options similar to ng-repeat . Please refer to this. https://docs.angularjs.org/api/ng/directive/ngOptions

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