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>
在这段代码中,我想只有经过内打印,使打印外,意味着除非我得到我想要的响应循环等待,然后去第二个循环,因为我已经定义了一个变量temp,并且我正在运行一个循环,直到它的值变为10,但即使在得到响应(如此评论)并将temp值设置为10. 请帮忙
你的意思是你想一次接一次地执行'get'调用3次吗? –
我想循环等待,直到它得到响应,然后去第二个循环,但它是连续3次,然后我得到的回应 – Abhishek
它应该像内部外部内部外部控制台 – Abhishek