zoukankan      html  css  js  c++  java
  • angularjs 绑定多个属性到下拉框

    绑定下拉框 angularjs  代码:

      //活动下拉切换
        $scope.activityChange = function () {
            
                        var cards = new Array();
                        var url = "/CustomCard/GetCustomCardListByAct";
                        $.ajax({
                            url: url,
                            type: 'Get',
                            async: false,
                            data: { actName: $scope.formData.SelectActivityType },
                            success: function (data) {
                                if (data != null) {
                                    $.each(data, function (i, n) {
                                        //, cu.IsBindDealerId,cu.IsBindVIN, cu.WriteOffNumber
                                        var cardinfo = { activity: n.ActivityType, cardid: n.CardType, cardtitle: n.CardTypeName, code: n.code, IsBindDealerId: n.IsBindDealerId, IsBindVIN: n.IsBindVIN, WriteOffNumber: n.WriteOffNumber }
                                  
                                        cards.push(cardinfo);
                                    });
                                    $scope.cardTypes = cards;
                                }
                            },
                            error: function (err) {
                                alert("error...");
                            }
                        });
    
                    
            }

    普通绑定下拉框 html 代码写法:

    <div class="form-group">
                            <label class="col-md-2 control-label">卡劵类型:</label>
                            <select ng-change="activityChangetype()" id="ii" class="col-md-2 form-control" ng-model="formData.SelectCardType" ng-options="m.cardid as m.cardtitle  for m in cardTypes" >
                                <option value="">请选择</option>
                      
                            </select>
                          
                        </div>

    普通取值下拉框值写法:

    //卡券类型下拉切换
        $scope.activityChangetype = function () {
            
                console.log("选择了卡券类型");
                //取到下拉框的Value
                console.log($scope.formData.SelectCardType);
               
            
        }

    绑定多个属性到下拉框 html 代码写法:

              <div class="form-group">
                            <label class="col-md-2 control-label">卡劵类型:</label>
                            <select ng-change="activityChangetype()" id="ii" class="col-md-2 form-control" ng-model="formData.SelectCardType"  ng-options="y.cardtitle for (x, y) in cardTypes">
                                <option value="">请选择</option>
                           
                            </select>
                          
                        </div>

    多个属性取值:

                         //卡券类型下拉切换
        $scope.activityChangetype = function () {
            
                console.log("选择了卡券类型");
                
                console.log($scope.formData.SelectCardType.cardid);
                console.log($scope.formData.SelectCardType.IsBindDealerId);
                console.log($scope.formData.SelectCardType.IsBindVIN);
                console.log($scope.formData.SelectCardType.WriteOffNumber);
                if ($scope.formData.SelectCardType.WriteOffNumber>1)
                {
                    console.log("选择的卡券可核销次数大于1");
                  //  $scope.formData.MovingCode.
                }
            
        }
  • 相关阅读:
    让你平步青云的10个谈话技巧
    瑞士心理学家和精神分析医师――荣格
    市场倍增理论
    淘宝网格,淘宝富人群
    波波的个人简历
    磁盘修复工具
    9种没结果的爱(未婚者必读)!!!
    网络投机市场
    网页数据抽取的方法介绍
    C#扩展方法试用
  • 原文地址:https://www.cnblogs.com/yangjinwang/p/7745068.html
Copyright © 2011-2022 走看看