Im working with angularjs $http.get() request .On load of the page im doing two rest api call.The api is executing correctly.I have a button which use the data from the two rest api calls.I'm facing a issue that is my function get executed before the $http.get() response and i'm not able to get the desired result.How can i make my function to execute after the response from the two $http.get() request. Can anyone help.i'm stuck at this point
var responsePromise5 = $http.get("1st rest call");
responsePromise5.success(function(data1) {
$scope.id = data1.platform.user.id;
var responsePromise = $http.get("2nd rest call");
responsePromise.success(function(data2)
{
console.log(data2.platform.record);
$scope.records= data2.platform.record;
});
responsePromise.error(function(data2, status, headers, config) {
alert("AJAX failed!");
});
});
responsePromise5.error(function(data1, status, headers, config) {
alert("AJAX failed!");
});
$scope.hello = function(a,b)
{
//here i want to call another rest api
}
<div ng-repeat="record in records">
{{record.name}}
<button ng-init=hello(record.unin,id)>abc</button>
</div>