title: AngularJS: tracking which checkbox is checked
body: <p>In an HTML form, I need to track which checkboxes get checked so I can insert it in my query object that is to be posted to the backend.</p>
  
  <p>I have the following three checkboxes in an array in the $scope:</p>
  
  <pre><code>$scope.typeCheckBoxes = [
        {label: "A", val: true},
        {label: "B", val: false},
        {label: "C", val: false}
      ];
  </code></pre>
  
  <p>and this below is my template for rendering the checkboxes in the form:</p>
  
  <pre><code>&lt;span ng-repeat="chk in typeCheckBoxes"&gt;
  &lt;input type="checkbox" ng-model="chk.val" id="chk.label" ng-change="addType(this)" /&gt;
              &lt;label&gt;{{chk.label}}&lt;/label&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>and in my controller, I tried to create the function <strong>addType()</strong> to add the checked checkbox to my query object:</p>
  
  <pre><code>$scope.queryObj = {
  types: []
  };
  
  $scope.addType = function(e) {
     var selectedBox = angular.element(e.id); // not working
     if (selectedBox) {
       $scope.queryObj.types.push(selectedBox);
     }
  
  };
  </code></pre>
  
  <p>However, I am not sure how I can get the <code>id</code> of the checked checkbox. your help is appreciated very much.</p>