angularjs - multiple $interval Angular JS prob -
the output of not want , don't know problem, should finish first interval after start second loop result :
my j : 4
my : 4
my j : 3
my : 5
my j : 2
my : 6
but want finish first loop after start second.
thanks in advance
var pos = new google.maps.latlng(53, 91); var j = $scope.map.zoom; $interval(function () { $scope.map.setzoom(j--); console.log(" j :"+j); }, 500, 3);// zoom out after 0.5 sec $scope.map.panto(pos); // pan map position var = $scope.map.zoom; $interval(function () { $scope.map.setzoom(i++); console.log("my :"+i); }, 500, 3);// zoom in after 0.5 sec
you can start second interval when promise first interval resolves:
$interval(function () { $scope.map.setzoom(j--); console.log(" j :"+j); }, 500, 3).then(function() { var = $scope.map.zoom; $interval(function () { $scope.map.setzoom(i++); console.log("my :"+i); }, 500, 3); });
Comments
Post a Comment