2014-09-25 38 views
1

我的HTML是角複選框NG-模型作爲陣列

<label> 
    <input type="checkbox" name="Communities" ng-model="formData.User.Communities" value="1" id="YOURROLE_0"> 
    COACH</label> 
<br> 
<label> 
    <input type="checkbox" name="Communities" ng-model="formData.User.Communities" value="2" id="YOURROLE_1"> 
    ATHLETE</label> 
<br> 
<label> 
    <input type="checkbox" name="Communities" ng-model="formData.User.Communities" value="3" id="YOURROLE_2"> 
    PARENT</label> 

如何指定的HTML/JavaScript的,我得到的模型如下圖所示。我需要複選框(選中的)作爲數組填充到數組中。

.controller('formController', function($scope) { 

     $scope.formData = { 
      "User": { 
       "Communities": [1, 2, 3] 
      } 
     }; 

    }); 

回答