var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
for(var i=0;i<2;i++){
//var temp;
$http.get("https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js")
.then(function(response) {
console.log("inside");
// temp=10;
});
//while(temp!=10){}
console.log("outside")}
});
<!DOCTYPE html>
<html ng-app="myApp" ng-controller="myCtrl">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</html>
In this code i want to make print outside only after inside prints,mean unless i receive the response i want to make the loop wait and then go for second loop,for this i have defined a variable temp and i'm running a loop until its value becomes 10,but its going into infinite loop even after getting response (so commented )and setting temp value to 10. Please help