this is my code and need to retrieve some parts of json data
this my json data,in this i need to retrieve topology-id,node-id,tp-id which is in nested json array so write some code just check that once, and i am very new to angularjs.so help me out with this issue
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-base64/2.0.5/angular-base64.js"></script>
<body>
<div ng-app="list">
<div ng-controller="ListCtrl">
<ul ng-repeat="data in network-topology">
<li >{{data.topology}}</li>
</ul>
</div>
<div ng-controller="ListCtrl">
<ul ng-repeat="data1 in topology">
<li >{{data1.topology-id}}</li>
</ul>
</div>
<div ng-controller="ListCtrl">
<ul ng-repeat="data2 in node">
<li >{{data2.node-id}}</li>
</ul>
</div>
<div ng-controller="ListCtrl">
<ul ng-repeat="data3 in termination-point">
<li >{{data3.tp-id}}</li>
</ul>
</div>
<script>
var app = angular.module('list', ['base64']);
app.controller('ListCtrl', function($scope, $http, $base64) {
$http.defaults.headers.common = {"Access-Control-Request-Headers": "accept, origin, authorization"};
$http.defaults.headers.common['Authorization'] = 'Basic ' + $base64.encode('admin' + ':' + 'admin');
$http({
method: 'GET',
url: 'http://10.132.32.212:8181/restconf/operational/network-topology:network-topology/',
contentType: 'application/json; charset=utf-8',
}).success(function(tdata) {
$scope.network-topology= tdata.network-topology;
$scope.topology= tdata.topology;
$scope.topology-id = tdata.topology-id;
$scope.node-id = tdata.node-id;
$scope.tp-id = tdata.tp-id;
$scope.topology= [];
$scope.node= [];
$scope.termination-point= [];
angular.forEach(tdata.network-topology, function(network-topology, index){
angular.forEach(network-topology.topology, function(topology, index){
angular.forEach(network-topology.topology.node, function(node, index) {
angular.forEach(network-topology.topology.node.termination-point, function(termination-point, index){
$scope.termination-point.push(termination-point);
});
});
});
});
</script>
</body>
</html>
tdata
– Nishant123 1 hour ago