I am new to AngularJS and trying to make an application which loads data by calling APIs. It is like I am fetching the list of boxes of type A (Resource Groups) and then each Box of type A has multiple boxes of type B (Virtual Machines). So I have been able to fetch all type A boxes and by using each value of type A box, I have been able to fetch all type B boxes(VMs). But now how shall I put the VM's in respective resource group's panel-body.
(function() {
var app = angular.module('AzureManager', []);
app.controller('resourceGroupsController', function($scope, $http) {
$scope.getRGList = function() {
$http.get('/resource-group/all').then(function(response) {
$scope.resourceGroups = response.data.value;
});
};
$scope.getRGList();
});
})();
<!DOCTYPE HTML>
<HTML ng-app="AzureManager">
<head>
<title>Azure Manager</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.1/angular.min.js"></script>
<script src="public/app.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#topNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Azure Manager</a>
</div>
<div class="collapse navbar-collapse" id="topNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Anant</a>
</li>
<li><a href="#"><span class="glyphicon glyphicon-log-out"></span> Logout</a>
</li>
</ul>
</div>
</div>
</nav>
<section class="container-fluid" ng-controller="resourceGroupsController">
<div class="panel panel-default" ng-repeat="RG in resourceGroups" id="{{RG.name}}-resources-container">
<div class="panel-heading">
<div class="panel-title">{{RG.name}}</div>
</div>
<div class="panel-body"></div>
</div>
</section>
</body>
</HTML>