Home > DeveloperSection > Forums > How to Bind Mixed Json data in AngularJS
Ankit Singh

Total Post:341

Points:2389
Posted on    February-25-2016 10:13 PM

 Angular JS JQuery  Angular JS 
Ratings:


 1 Reply(s)
 302  View(s)
Rate this:
We want to Bind Mixed Json data  in AngularJS. How to bind this Please tell me.


aditya kumar Patel

Total Post:246

Points:1752
Posted on    February-25-2016 10:15 PM

@{

Layout = null;

}

<!DOCTYPE html>

<html>

<head>

<title>Forum</title>

<meta name="viewport" content="width=device-width" />

<script src="~/Scripts/jquery-1.9.1.js"></script>

<script src="~/Scripts/angular.js"></script>

<script>

var app = angular.module("myApp", []);

app.controller('MyCtrl', function ($scope) {

$scope.alldata = [

{

"CompanyName":"Software Pvt Ltd",

"Employees": ["Johan Kumar", "Anupam Singh", "Surekha Pal", "Maya Koni"],

"awards": [

{

"award": "Gold Partner",

"year": 2000,

"by": "Microsoft"

},

{

"award": "Gold Partner",

"year": 2001,

"by": "IBM"

}]

}];

});

</script>

</head>

<body ng-app="myApp" ng-controller="MyCtrl">

<table>

<tbody ng-repeat="dat in alldata">

<tr>

<td colspan="3">{{dat.CompanyName}}</td>

</tr>

<tr>

<td colspan="3" align="center"><span style="font-weight:bold">Employees</span></td>

</tr>

<tr ng-repeat="cont in dat.Employees">

<td colspan="3">{{ cont}}</td>

</tr>

<tr>

<td colspan="3" align="center"><span style="font-weight:bold">Awards</span></td>

</tr>

<tr ng-repeat="aw in dat.awards">

<td>{{ aw.award}}</td>

<td>{{ aw.year}}</td>

<td>{{ aw.by}}</td>

</tr>

</tbody>

</table>

</body>

</html>


Don't want to miss updates? Please click the below button!

Follow MindStick