Ng-checked Select and click Add Dom

Source: Internet
Author: User

1. Requirements

The selection of a checkbox is implemented in the Add page, and then it is automatically selected when the Detail page is displayed.

2. Add a page

Crossing better copy this code over to see the effect.

<! DOCTYPE html>

3. Detailed Display

Suppose the result of adding a page is: $scope. result = [3,2];

<! DOCTYPE html>

{"List": [{"Content": "Free text invoice", "type": 1},{"Content": "Electronic Product", "type": 2}]} to be passed to the background of the data page display above the type=1, add the following fill type=2

 html                div.form-group      & nbsp             label.control-label.col-md-3 invoice type             &NBSP ;       div.col-md-6                        label . Checkbox.pull-left (ng-repeat= "(key,type) in  globalconfig.invoice_type"   style= "margin-left:30px")                                 input (type = "checkbox" Name= "Invoice_type" ng-model= "Invoice_type[key]" ng-true-value= "true"   ng-false-value= "" ng-click= ")                                 | {{type}}                       //-Select.form-control (ng-opt Ions= "Key as value for (key,value) in GlobalcoNfig.invoice_type "ng-model=" Info.list.invoice_type "multiple=" true ")               & nbsp        //-         option (value= ") (Invoice type can be selected)        &NBS P         div.form-group                    Label.cont Rol-label.col-md-3 Invoice content                     div.col-md-6    &NB Sp                   .form-group                            Span.btn.btn-danger (ng-click= "ADDFN (senddata.list)") Add     &N Bsp                       DIV (ng-repeat= "spec in senddata.list")                                 INPUT-GROUP&NBSP ;   &nbsp                               Input.form-contro L (type= "text" ng-model= "spec.content" Name= "Brand_Name")                   &N Bsp                 Input-group-addon (ng-click= "Removefn (senddata.content,spec)")                          ,         &NB Sp     I.glyphicon.glyphicon-remove  js angular.module (' laoyou '). Controller (' Invoicectrl ', [' $scope ', ' $http ', ' $stateParams ', ' API ', function ($scope, $http, $stateParams, API) {           $scope. SendData = {list:[]};        $scope. Addfn=function (List,item) {      & nbsp    //Console.log (list)            //[{type:2, Content: "ERT"}, {type:2, conte NT: "FGH"}]    &NBSp       List.push ({type:2});           /*if (list = = undefined) {    & nbsp           list = [];                     & nbsp    }else{                List.push ({});        &NBS P  }*/        }        $scope. Removefn=function (List,item) {  & nbsp         var index=list.indexof (item);            List.splice (index,1) &N Bsp      } //      Initialize invoice_type        $scope. invoice_type={};& nbsp;        $scope. SENDFN = function () {             Senddata=ang Ular.copy ($scope. SendData);            //senddata= {};        &NB Sp //senddata.content = $scope .senddata.content;             var type= [{"Content] : "Free text invoice", "type": 1},{"Content": "VAT Exclusive Invoice", "type": 1},{"Content": "Electronic Invoice", "type":1}];            //senddata.type=[];            var invoice= $scope .invoice_type;            Console.log (invoice)             for (var x in invoice) {  &N Bsp             if (invoice[x]) {                  &N Bsp SendData.list.push (Type[x-1]); Incoming desired number                }           }   & nbsp          console.log (senddata);             /*var info = {};&N Bsp            info.list = [senddata];*/          &NBSP Console.log (info);            $http. Post ("Invoice/save", SendData). Success (Function ( Data) {                if (data.statuscode = = = ' 0 ') {        & nbsp           alert ("Submit Success");                   /*i F ($scope. Pagemodel = = = ' Add ') {                        $state . Go ("Home.employee.view", {                          &NBS P id:data.data                       })       &N Bsp            }else{                    &NBS P   $state. Go ("Home.employee.view", {                      &NBSP ;     ID: $stateParams .id                       })   &N Bsp                }*/               }           })        }   }])

Ng-checked Select and click Add Dom

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.