duterte duterte - 9 months ago 22
PHP Question

Get the value of the checked checkbox in angularjs

I am new to angularjs. And I am currently developing a web app. I have 10 checkboxes inside my form. I don't know how to get the value of the checked checkbox. After getting the value of the checkbox, it will be saved in my database, together with other input types. How to do it? I am new to angular.

<input type="checkbox" value="Wifi" name="wifi"><i class="fa fa-wifi fa-lg"></i> Wifi Internet
<input type="checkbox" value="kitchen" name="kitchen"><i class="fa fa-cutlery fa-lg"></i> Kitchen
....

Answer Source

You need to add ng-models.

<input ng-model="wifi" type="checkbox" value="Wifi" name="wifi">
<input ng-model="kitchen" type="checkbox" value="kitchen" name="kitchen">
..etc

Then in your controller:

$scope.wifi // true or false
$scope.kitchen // true or false

Once you have these values in your controller, you can send the checkbox data to a server to do with as it wishes.