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

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

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

select標簽的對于大家來說很熟悉了,下面我來講講AngularJS中 對select的屬性設置,做出選擇某個下拉選項后控制其他標簽的隱藏;

<select style="height:31px; width:100px" id="rewardMethod"name="rewardMethod" class="status_select" ng-model="state">
<option value="0" ng-selected='rewardMethod == "0"'>自動發(fā)放</option>
<option value="1" ng-selected='rewardMethod == "1"'>指定中獎人</option>
<option value="2" ng-selected='rewardMethod == "2"'>不發(fā)放獎品</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>獎品發(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中設ng-model = “state”雙向綁定數(shù)據(jù),他的值會隨你選擇下拉項而改變,就是選中的option的value;在下面的div中設置ng-if="state == 1" 進行控制;

當頁面進行修改操作的時候,需要把原來的值填入表單中,所以加了ng-selected='rewardMethod == "2"'

在controller。js中設置$scope.rewardMethod=2;這樣加載頁面就會選中第三項;效果如下:

這里寫圖片描述

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

這里寫圖片描述

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論