欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

angularjs實(shí)現(xiàn)下拉列表的選中事件示例

 更新時(shí)間:2017年03月03日 08:51:10   作者:韓小文  
本篇文章主要介紹了angularjs實(shí)現(xiàn)下拉列表的選中事件示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

select標(biāo)簽的對(duì)于大家來(lái)說(shuō)很熟悉了,下面我來(lái)講講AngularJS中 對(duì)select的屬性設(shè)置,做出選擇某個(gè)下拉選項(xiàng)后控制其他標(biāo)簽的隱藏;

<select style="height:31px; width:100px" id="rewardMethod"name="rewardMethod" class="status_select" ng-model="state">
<option value="0" ng-selected='rewardMethod == "0"'>自動(dòng)發(fā)放</option>
<option value="1" ng-selected='rewardMethod == "1"'>指定中獎(jiǎng)人</option>
<option value="2" ng-selected='rewardMethod == "2"'>不發(fā)放獎(jiǎng)品</option>
</select>

<div class="form-group" ng-if="state != 2">
            <label class="col-sm-3 control-label no-padding-right"
                for="form-field-1">優(yōu)惠券</label>
            <div class="col-sm-9">
              <select style="height:31px; width:100px" id="reward"
                  name="reward" class="status_select">
                <option ng-repeat='item in couponList' ng-value="item.id"
                    ng-selected="couponInfoid == item.couponName">{{item.couponName}}
                  總數(shù):{{item.countLimit}}
                </option>
              </select>
            </div>
          </div>
          <div class="form-group" ng-if="state == 0">
            <label class="col-sm-3 control-label no-padding-right"
                for="form-field-1"><span class="red">*</span>獎(jiǎng)品發(fā)放數(shù)量</label>
            <div class="col-sm-9">
              <input type="text" name="rewardProvideCount" id="rewardProvideCount"
                  class="form-control"
                  check-type="required">
            </div>
          </div>
        </form>
      </div>

其中在select中設(shè)ng-model = “state”雙向綁定數(shù)據(jù),他的值會(huì)隨你選擇下拉項(xiàng)而改變,就是選中的option的value;在下面的div中設(shè)置ng-if="state == 1" 進(jìn)行控制;

當(dāng)頁(yè)面進(jìn)行修改操作的時(shí)候,需要把原來(lái)的值填入表單中,所以加了ng-selected='rewardMethod == "2"'

在controller。js中設(shè)置$scope.rewardMethod=2;這樣加載頁(yè)面就會(huì)選中第三項(xiàng);效果如下:

這里寫圖片描述

如果選擇不發(fā)獎(jiǎng):

這里寫圖片描述

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論