title: AngularJS checkbox ng-repeat and selected objects?
body: <p>I am trying to do it in proper way with less pain, but i can't figure out how to deal with ng-model and binding it to the selected list etc and moreover i need to populate that list in later time and keep selected objects in it.</p>
  
  <pre><code>categories = [ { "name": "Sport", "id": "50d5ad" } , {"name": "General", "id": "678ffr" } ]
  
      &lt;span ng-repeat="category in categories"&gt;
        &lt;label class="checkbox" for="{{category.id}}"&gt;
          &lt;input type="checkbox" value="{{category.id}}" ng-model="??" ng-click="??" name="group" id="{{category.id}}" /&gt;
          {{category.name}}
        &lt;/label&gt;
      &lt;/span&gt;
  </code></pre>
  
  <p>I have to override the categories each time the list is populated since it will be pulled out from a server. </p>
  
  <p>So I guess I need to have arrays and the second one will hold the selected objects? </p>
  
  <p>If I am right, how do I preselect checkboxes? </p>
  
  <p>Do I need ng-click in order call custom function to store the selected object in the other array? </p>
  
  <p>Do I need ng-model in checkbox And what for? </p>
  
  <p>What is the proper-way with less pain?</p>