• Angular JS ng-model对<select>标签无效的情况


    使用场景一:

    <select ng-if="item.award_type==1" id="award{{$index+1}}" name="XXXXX[award{{$index+1}}]" ng-model="item.award">
          <option ng-repeat="(key, value) in List track by $index" value="{{key}}">{{value}}</option>
    </select>

    使用场景二:

    <select id="award_type{{$index+1}}" name="XXXXX[award_type{{$index+1}}]" ng-model="item.award_type" ng-change="changeAwardType($index)">
           <option value="0">请选择奖品</option>
           <option value="1">商品券</option>
           <option value="2">优惠券</option>
           <option value="3">实物奖励</option>
    </select>

    <select> - <option> 配合 ng-model 使用的话

    如果是场景二, ng-model 绑定数据后,下面的 <option> 能随 ng-model 绑定的数据改变,即将对应value的<option>设为selected;

    如果是场景一,<option> 使用 ng-repeat 绑定数据,<select>用 ng-model 绑定则无法起到将对应的<option>设为selected,此时代码得做相应的修改,使用ng-selected进行处理

    <select ng-if="item.award_type==1" id="award{{$index+1}}" name="XXXXX[award{{$index+1}}]" ng-model="item.award">
          <option ng-repeat="(key, value) in List track by $index" value="{{key}}" ng-selected="item.award==key?'selected':''">{{value}}</option>
    </select>
  • 相关阅读:
    禁止后台运行
    图标的圆角和光晕效果和启动画面
    IOS 开发 有关iPhone程序的安装目录UUID 唯一标识
    NSOperation与performSelectorOnMainThread
    Java web开发学习规划
    JAVA类集
    java 四种xml操作方式的基本使用方法
    用JDOM操作XML文件
    java web 学习
    过去的,将来的
  • 原文地址:https://www.cnblogs.com/lyc94620/p/9728745.html
Copyright © 2020-2023  润新知