I want to iterate and get the name values: test01, test02 and test03 on my ng-repeat for my given json. How can I get it using ng-repeat ? Please let me know and thanks in advance.
Fiddle is available.
I want to iterate and get the name values: test01, test02 and test03 on my ng-repeat for my given json. How can I get it using ng-repeat ? Please let me know and thanks in advance.
Fiddle is available.
You can do it like this:
<tr ng-repeat="(key, value) in data.Test">
<td> {{value.Testing.static.name}} </td>
</tr>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.data = {
"Test": [{
"Testing": {
"static": {
"name": "test01"
},
"testboolean": true
}
}, {
"Testing": {
"static": {
"name": "test02"
},
"secondstatic": "yes"
}
}, {
"Testing": {
"static": {
"name": "test03"
}
}
}]
};
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
<table>
<tr ng-repeat="d in data.Test">
<td> {{d.Testing.static.name}} </td>
</tr>
</table>
</div>
Something like this will do the trick:
<div ng-controller="MyCtrl">
<table>
<tr ng-repeat="value in data.Test">
<td> {{value.Testing.static.name}} </td>
</tr>
</table>
</div>
If you are sure that the hierarchy of your JSON will remain the same, then there is no need to iterate in the json properties by using (key, value) in data.