I have a below JSON response, I need to populate my role information based on the role selected, I just moved roleinformation in roleInfo array , but the problem is I am unable to populate the key and value in the table accordingly.I am able to get the value , but couldnt populate in table. I couldn't move the key and its value to the table . I need move QA and Development with its sub key white box testing and Black box testing in my table. My for loop throw at error at end of termination.
JSON:
{
"json": {
"response": {
"servicetype": "1",
"functiontype": "10011",
"statuscode": "0",
"statusmessage": "Success",
"data": {
"unassignedroles": [
{"rolename":"1",
"roleinformation": {
"QA": [
{
"White Box Testing": 0
},
{
"Black Box Testing": 10
}
],
"Development": [
{
"White Box Testing": 0
},
{
"Black Box Testing": 10
}
]
}
},
{
` "rolename":"2"`,
"roleinformation": {
"1": [
{
"A": 0
}
]
}
}
JS:
var roleInfo = [];
UserService.getAssignRoles(json).then(function(response) {
if (response.json.response.statuscode == 0 && response.json.response.statusmessage == 'Success')
{
$scope.model.assignroles = [], assignrolesArray = [];
var unasresdata = response.json.response.data.unassignedroles;
var assresdata = response.json.response.data.assignedtoles;
assignrolesArray = unasresdata.concat(assresdata);
$scope.model.assignroles = assignrolesArray;
for( var i = 0; i < assignrolesArray.length ; i++){
if (($scope.model.rolename === assignrolesArray[i].rolename) && (assignrolesArray[i].rolename !== undefined )){
roleInfo = assignrolesArray[i].roleinformation;
for (i in roleInfo)
}
}
}
});
HTML:
<select class="form-control" name="role"
ng-model="model.rolename"
ng-change="getAssignRole(data,model.rolename)">
<option selected>Select Roles</option>
<option ng-repeat="role in model.assignroles track by $index"
value="{{role.rolename}}">{{role.rolename}}</option>
</select>
<div>
<table class="smalltable">
<thead>
<tr ng-repeat="i(key, value) in roleInfo">
<td>{{ key }}</td>
<td ng-repeat="details in value">
` <p ng-repeat"(subkey, subvalue) in details">{{ subkey }} : {{ subvalue }}</p>
</td>
</tr>
</thead>
</table>
</div>
for (i in roleInfo)
doesn't have any content... – Daniel Sep 29 at 10:43