checkbox input

http://stackoverflow.com/questions/14834300/angularjs-checkbox-ng-repeat-and-seleted-objects

by leighboone

HTML

<div ng-controller="Ctrl">
    <span ng-repeat="category in categories">
      <label class="checkbox" for="{{category.id}}">
        <input type="checkbox" ng-model="selection.ids[category.id]" name="group" id="{{category.id}}" />
        {{category.name}}
      </label>
    </span>
    <pre ng-bind="selection.ids | json"></pre>    
</div>

JavaScript

var app = angular.module('app', []);

function Ctrl($scope) {
   
    $scope.selection = {
        ids: {"50d5ad": true}
    };

    $scope.categories = [ { "name": "Sport", "id": "50d5ad" } , {"name": "General", "id": "678ffr" } ];
    
}