Angularjs binding multiple properties to a drop-down box

Source: Internet
Author: User

Binding the Drop Box Angularjs code:

  //Active Pull -down toggle$scope. Activitychange =function () {varCards =NewArray (); varURL ="/customcard/getcustomcardlistbyact"; $.ajax ({url:url, type:'Get',                        Async:false, data: {actname: $scope. Formdata.selectactivitytype}, Success:functi On (data) {if(Data! =NULL) {$.each (data, function (I, n) {//, cu. Isbinddealerid,cu. Isbindvin, cu. Writeoffnumber                                    varCardinfo ={activity:n.activitytype, Cardid:n.cardtype, Cardtitle:n.cardtypename, Code:n.code, Isbinddealerid:n.isbinddea                                                                  Lerid, Isbindvin:n.isbindvin, Writeoffnumber:n.writeoffnumber}                                Cards.push (Cardinfo);                                }); $scope. Cardtypes=cards; }}, Error:function (err) {alert ("error ...");                        }                    }); }

Common binding drop Box HTML code notation:

<Divclass= "Form-group">                        <labelclass= "Col-md-2 Control-label">Kari Type:</label>                        <SelectNg-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" >                            <optionvalue="">Please select</option>                                          </Select>                                          </Div>

Normal value drop-down box value notation:

// Card Coupon Type drop-down toggle    $scope. Activitychangetype = function () {                    console.log (" card type selected ");             // value from the drop-down box             Console.log ($scope. formdata.selectcardtype);                       }

To bind multiple attributes to the drop-down box HTML code notation:

          <Divclass= "Form-group">                        <labelclass= "Col-md-2 Control-label">Kari Type:</label>                        <SelectNg-change= "Activitychangetype ()"ID= "II"class= "Col-md-2 Form-control"Ng-model= "Formdata.selectcardtype"ng-options= "Y.cardtitle for (x, y) in Cardtypes">                            <optionvalue="">Please select</option>                                               </Select>                                          </Div>

Multiple attribute values:

                     //Card Coupon Type drop-down toggle$scope. Activitychangetype =function () {Console.log ("type of card coupon selected");            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 ("the number of cards you choose can be more than 1"); //$scope. Formdata.movingcode .            }            }

Angularjs binding multiple properties to a drop-down box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.