Nicoleta Wilskon Nicoleta Wilskon - 1 month ago 4
JSON Question

How to display values of array in json format in table

I have var customer array and I stored my response in that array. Now I need to populate the values to table, if

intrstd
present in response.

I am unable to get that .

JSON:

var customer =
[
[
{
"businessuserid": 52,
"businessusername": "Cars workshop",
"businessusermobile": "9535000636",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": true,
"emailvalidated": false,
"email": "preethi@car.com",
"upin": "000052"
},
{
"businessuserid": 59,
"businessusername": "MCF Business",
"businessusermobile": "00",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": true,
"emailvalidated": false,
"email": "pavanhachholli@groupz.in",
"upin": "000059"
}
],
[
{
"businessuserid": 44,
"businessusername": "rk business New",
"businessusermobile": "00",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": false,
"emailvalidated": false,
"email": "riteshnew@gmail.com",
"upin": "000044"
}
],
[
{
"approved": true,
"businessuserid": 43,
"businessusername": "Cakey Bakes",
"businessusermobile": "8050663763",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": true,
"emailvalidated": false,
"email": "preethi@groupz.com",
"upin": "000043"
}
],
[
{
"intrsted": true,
"attended": false,
"businessuserid": 44,
"businessusername": "rk business New",
"businessusermobile": "00",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": false,
"emailvalidated": false,
"email": "riteshnew@gmail.com",
"upin": "000044"
}
],
[
{
"intrsted": true,
"attended": false,
"businessuserid": 52,
"businessusername": "Cars workshop",
"businessusermobile": "9535000636",
"businessusercountrycode": "91",
"admin": true,
"mobilevalidated": true,
"emailvalidated": false,
"email": "preethi@car.com",
"upin": "000052"
}
]


JS:

$scope.userdetails = function(){
for(var i=0;i<$scope.newuserlist[i].length;i++){


for(var j=0;j<$scope.interested.length;j++){

if($scope.interested[j].intrsted == undefined){
$scope.undefinedprogram = "null";
}
else if($scope.interested[j].intrsted == true){
$scope.users = $scope.interested[j].businessusername;
console.log($scope.users );
$scope.modalvalues.push($scope.users);
console.log($scope.modalvalues);
}
}
}

};


If I am able to fetch only array values where
"intrsted":
tag is present,I will be able to populate the value in table accordingly.

Kev Kev
Answer

Assuming angularjs since you have the angularjs tag. You could use ng-repeat to loop through your data, and use a filter to display only the relevant records:

<table>
    <tr ng-repeat="item in your.controller.your.data | filter: { intrsted: true }">
        <td>{{item.businessusername}}</td>
        ...
    </tr>
</table>

But really, this is the most basic angularjs application possible. You can get this information from any beginner tutorial.