Can you please advise on how to extract the value from a radio button and send it using $http.post in AngularJS? Here is an example:
HTML
<input name="group1" type="radio" id="test1" value="4"/>
<label for="test1">Four paintings</label>
<input name="group1" type="radio" id="test2" value="6" />
<label for="test2">Six paintings</label>
<button ng-click="submit()">Submit</button>
One radio button has a value of 4, and the other has a value of 6. These values need to be sent to Angular and then saved in the database.
Angular
$scope.submit = function(){
// assuming radioValue stores the selected value from radio buttons
if ( radioValue == 4 ) {
$http.post(apiURL, {
numberOfpaintings: radioValue,
...
});
} else if( radioValue == 6 ) {
$http.post(apiURL, {
numberOfpaintings: radioValue,
...
});
}
}
The 'radioValue' variable needs to store the value from the selected radio button before sending it through $http.post. Thanks!