首页 > 代码库 > angularJS动态设置ng-model

angularJS动态设置ng-model

<div class="form-group" >
                              
 <label class="col-xs-2 control-label col-xs-offset-1"><span 
class="red">*</span>系统选择</label>
                               <div class="col-xs-9">
                                   <div class="col-xs-3 pl0" ng-repeat="param in params">
                                   <div class="radio c-radio">
                                       <label>
  
                                         <input ng-show="ls" 
type="checkbox" name="radioSys" class="checkSysId radioSys" 
ng-true-value="http://www.mamicode.com/{{param.sysId}}" value="http://www.mamicode.com/{{param.sysId}}"  
ng-trim="false"  ng-click="getSysId($parent.conff[$index])" 
ng-model="$parent.conff[$index]">
                                           <span  ng-show="ls" class="fa fa-check"></span>{{param.sysName}}
                                       </label>
                                   </div>
                                   </div>
                               </div>
                           </div>
                 //点击获取系统ID
                    $scope.getSysId = function(t){
                        u="";
//                        $("#s1 option").remove();
//                        $("#s2 option").remove();
                        t="";
                        for(var prop in $scope.conff){
                             if($scope.conff[prop] != false){
                                 t+=$scope.conff[prop];
                                 t=t+‘\,‘;
                                 var k = $scope.conff[prop];
                                 var CoreUrl2 = new coreUrl({"transCode":"B000603","sysId":k});
                                     CoreUrl2.$save(function(objc){
                                         u+=objc.row[0].sysName;
                                         u=u+‘ ‘
                                         $scope.uu = u;
                                     });
                             }
//                             if($scope.conff[prop] != false){
//                                 t+=$scope.conff[prop];
//                                 t=t+‘\,‘;
//                             }
                         }
                        t = t.substr(0,t.length-1);
                        $scope.userSysList = t
                    };

利用$index判断获取选中的checkbox


本文出自 “紫枫5966” 博客,请务必保留此出处http://zifeng5966.blog.51cto.com/8763113/1947645

angularJS动态设置ng-model