angularjs 绑定多个属性到下拉框

2021-05-17 10:27

阅读:354

标签:options   blog   data   活动   code   success   console   nbsp   下拉   

 

绑定下拉框 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.
            }
        
    }

 

angularjs 绑定多个属性到下拉框

标签:options   blog   data   活动   code   success   console   nbsp   下拉   

原文地址:http://www.cnblogs.com/yangjinwang/p/7745068.html


评论


亲,登录后才可以留言!