
Hi i am Trying to Bind JSON object Data to a table.my issue is i am able to bind entire json object {{metric}} but failed to load each atttribute of json object i.e.,{{metric.EmpId}}.
finally from my observation i found when the converted json object is directly asigned to
$scope.Employees="Employee": [ {"EmpId": "4", "Name": "Chris", "Sex": "Male", "Phone": [ { "_Type": "Home", "__text": "564-555-0122" }, { "_Type": "Work", "__text": "442-555-0154" } ], "Address": { "Street": "124 Kutbay", "City": "Montara", "State": "CA", "Zip": "94037", "Country": "USA" } } ] }
the output is working as i expected but when i assign the direct result
i.e,$scope.Employees=response;it is not working what might be the issue
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="xml2json.js"></script>
<script>
var app = angular.module('httpApp', []);
app.controller('httpController', function ($scope, $http) {
$http.get("File1.xml",
{
transformResponse: function (cnv) {
var x2js = new X2JS();
var aftCnv = x2js.xml_str2json(cnv);
return aftCnv;
}
})
.success(function (response) {
console.log(response);
$scope.Employees = response;
console.log($scope.Employees);
});
});
</script>
<div>
<div ng-app="httpApp" ng-controller="httpController">
<div ng-repeat="metric in Employees">
{{ metric}}
<br />
<br />
<table>
<tr ng-repeat="metric in Employees">
{{metric}}
<td ng-repeat="cell in metric">{{cell}}</td>
<td>{{cell.EmpId}}</td>
<td>{{metric.Name}}</td>
</tr>
</table>
</div>
</div>