相关疑难解决方法(0)

如何使用angular JS设置下拉列表控件的选定选项

我正在使用Angular JS,我需要使用angular JS设置下拉列表控件的选定选项.请原谅我,如果这很荒谬,但我是Angular JS的新手

这是我的html的下拉列表控件

 <select ng-required="item.id==8 && item.quantity > 0" name="posterVariants"
   ng-show="item.id==8" ng-model="item.selectedVariant" 
   ng-change="calculateServicesSubTotal(item)"
   ng-options="v.name for v in variants | filter:{type:2}">
  </select>
Run Code Online (Sandbox Code Playgroud)

填充后,我得到了

 <select ng-options="v.name for v in variants | filter:{type:2}" ng-change="calculateServicesSubTotal(item)"
ng-model="item.selectedVariant" ng-show="item.id==8" name="posterVariants"
ng-required="item.id==8 &amp;&amp; item.quantity &gt; 0" class="ng-pristine ng-valid ng-valid-required">
    <option value="?" selected="selected"></option>
    <option value="0">set of 6 traits</option>
    <option value="1">5 complete sets</option>
</select>
Run Code Online (Sandbox Code Playgroud)

如何设置value="0"要选择的控件?

selected angularjs drop-down-menu angular-ngmodel

138
推荐指数
4
解决办法
49万
查看次数