Within the angular app.js file, I am dynamically populating a form with multiple select boxes, each having a unique id. How can I retrieve the selected values from these select boxes within the controller?
A variable has been added:
$scope.sibling_type = {};
Javascript code for loading the select box:
$scope.linkSiblingFinish = function(sibling){
var str_siblingtype = "<div class='col-sm-2' style='margin-bottom:15px'>" +
"<select ng-model='sibling_type[" + sibling.id + "]' class='form-control' id='sibling_type_"+sibling.id+"'>" +
"<option class='ng-binding ng-scope' value='1'>Sister->Brother</option>" +
"<option class='ng-binding ng-scope' value='2'>Brother->Sister</option>" +
"<option class='ng-binding ng-scope' value='3'>Sister->Sister</option>" +
"<option class='ng-binding ng-scope' value='4'>Brother->Brother</option>" +
"</select></div>";
document.getElementById('div_siblings').innerHTML = str_siblingtype;
}
The above script will be executed on a button click, passing a different 'id' to the 'sibling' parameter every time it is called. Assuming it's called twice with the ids '23' and '24', two select boxes will be created: 'sibling_type_23' and 'sibling_type_24'.
For the submit button:
$scope.saveSibling = function(data){
dataFactory.httpRequest('index.php/students/sibling/'+$scope.form.id,'POST',{},$scope.form).then(function(data) {
});
}
How can I bind/assign the option values so that when the form is submitted, I can access the selected options from those select boxes within the Laravel controller?