I have two checkboxes in the form now user can select one or both and post the data to server, But i am not sure,how i will bind both values to $scope.ng-model
when user post the data ?
main.html
<div class="col-md-8 col-md-offset-2">
<label class="checkbox">
<input type="checkbox" ng-value="'uploadPrc'" ng-model="prcModel">Upload PRC
</label>
<label class="checkbox">
<input type="checkbox" ng-value="'uploadPrt'" ng-model="prtModel">Upload PRT
</label>
</div>
angulars "two way data binding" works like this: Initialize your form data on the controller scope
$scope.form = {
prcModel: false,
prtModel: false
}
And in your view:
<div class="col-md-8 col-md-offset-2">
<label class="checkbox">
<input type="checkbox" ng-value="'form.prcModel'" ng-model="form.prcModel">Upload PRC
</label>
<label class="checkbox">
<input type="checkbox" ng-value="'form.prtModel'" ng-model="form.prtModel">Upload PRT
</label>
</div>
If you change the value of your checkboxes the value of your model will instantly change as well.
So all you need to do is deal with your $scope.form
in your controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With