angularjs check box validation
HTML
<div data-ng-controller="myController">
<form data-ng-submit="validate()">
<label>Message to:</label>
<span class="checkbox-group">
<input type="checkbox" name="mobile" data-ng-model="formData.mobile" />
<label for="mobile">Mobile</label>
</span>
<span class="checkbox-group">
<input type="checkbox" name="email" data-ng-model="formData.email" />
<label for="email">Email</label>
</span>
<input type="submit" value="Submit" />
</form>
</div>
JavaScript
function myController( $scope ){
$scope.formData = {
mobile : false, //initialize them to false, since by default they are undefined
email : false
}
$scope.validate = function(){
if($scope.formData.mobile == false || $scope.formData.email == false)
{
alert('You\'ve not checked \'em all!')
}
else{
alert('You\'ve checked \'em all!')
}
}
}