Angular checkboxes example
Trying to make it work with required
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
<div ng-controller="myCtrl">
<form name="myForm" ng-submit="submitSurvey(survey)">
<span ng-repeat="choice in choices">
<label class="checkbox">
<input type="checkbox" required="required" value="{{choice.id}}" ng-change="updateQuestionValues()" ng-model="choice.checked" name="group-one" />
{{choice.label}}
</label>
</span>
<input type="submit" value="Send" ng-disabled="myForm.$invalid" />
</form>
{{value}}
</div>
JavaScript
function myCtrl($scope) {
$scope.choices = [{
"id": 1,
"value": "1",
"label": "Good"},
{
"id": 2,
"value": "2",
"label": "Ok"},
{
"id": 3,
"value": "3",
"label": "Bad"}];
$scope.value = [];
$scope.updateQuestionValues = function() {
$scope.value = _.filter($scope.choices, function(c) {
return c.checked;
});
};
}