After making an AJAX request and receiving JSON data, I have created a list of radio buttons with values from the response. Although I have successfully bound the values to the list, I am facing difficulty in retrieving the selected value. Below is a snippet of my attempted code:
HTML
<ons-list-item modifier="tappable" ng-repeat="area in AreaList">
<label class="checkbox checkbox--list-item">
<input type="radio" ng-bind="area.name" ng-model="selectedValue" name="area" value="area.code">
<div class="checkbox__checkmark checkbox--list-item__checkmark"></div>
{{area.name}}
</label>
</ons-list-item>
JavaScript
// Parsing for Area
if(data.Details[i] === "Area"){
for(var d=0;d<17;d++){
var area = data.Details[i+1][d]['varCityName'];
var code = data.Details[i+1][d]['intGlCode'];
$scope.AreaList.push({name:area, code:code});
area = '';
code = '';
$scope.selectedValue = data.Details[i+1][d]['intGlCode'];
}
console.log("===========AREA obj===========", $scope.AreaList);
}
$scope.submitAnswer=function(list,rate,areaobj){
gList = list.name;
alert("-----------my selected area is=========="+gArea);
};
Printed Area Object in Console (long)
[
Object{
name="Camana Bay",
code="32"
},
Object{
name="Breakers",
code="1"
},
Object{
name="Grand Cayman",
code="2"
},
Object{
name="Bodden Town",
code="16"
},
Object{
name="Cayman Brac",
code="15"
},
Object{
name="East End",
code="20"
},
Object{
name="George Town",
code="21"
},
Object{
name="George Town West",
code="22"
},
Object{
name="Little Cayman",
code="23"
}
]