Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created December 5, 2014 17:08
Show Gist options
  • Select an option

  • Save cpoDesign/bbede23e15e1f20cce4b to your computer and use it in GitHub Desktop.

Select an option

Save cpoDesign/bbede23e15e1f20cce4b to your computer and use it in GitHub Desktop.
Nice example how to use checkbox and bind data to model
<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>
var app = angular.module('app', []);
function Ctrl($scope) {
$scope.selection = {
ids: {"50d5ad": true}
};
$scope.categories = [ { "name": "Sport", "id": "50d5ad" } , {"name": "General", "id": "678ffr" } ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment