I am reading the below json value from a module.js and my question is exist below the json.
.controller('home.person',['$scope','$filter','personResource',function($scope,$filter,personResource) {
$scope.searchPerson = function() {
var params = $scope.search || {};
params.skip=0;
params.take =10;
$scope.personDetails =
{
"apiversion": "0.1",
"code": 200,
"status": "OK",
"mydata": {
"myrecords": [
{
"models": [
{
"name": "Selva",
"dob": "10/10/1981"
}
],
"Address1": "ABC Street",
"Address2": "Apt 123",
"City": "NewCity1",
"State": "Georgia"
},
{
"models": [
{
"name": "Kumar",
"dob": "10/10/1982"
}
],
"Address1": "BCD Street",
"Address2": "Apt 345",
"City": "NewCity2",
"State": "Ohio",
"Country":"USA"
},
{
"models": [
{
"name": "Pranav",
"dob": "10/10/1983"
}
],
"Address1": "EFG Street",
"Address2": "Apt 678",
"City": "NewCity3",
"State": "NewYork",
"Country":"USA",
"Zipcode" :"123456"
}
]
}
}
}
}])
I am currently fetching the value using the below angular code. This is fetching the all the json key/value attributes which i want to do customize. In the json output i don't to fetch Address 2,Zipcode. How can i achevie this in Angular JS?
<body ng-controller="AppController as vm">
<h1>Hello angular {{appVm.version}}</h1>
<div ng-show="vm.personDetails.mydata.myrecords.length > 0" ng-repeat="recordSingle in vm.personDetails.mydata.myrecords">
<div>
<span ng-repeat="(key, value) in recordSingle">
<span ng-switch='key'>
<span ng-switch-when='models'> name: {{value[0].name}}</span>
<span ng-switch-default>
{{key}}: {{value}}
</span>
</span>
</span>
</div>
</div>
<script src="//code.angularjs.org/1.3.2/angular.js"></script>
<script src="script.js"></script>
</body>