I have the following controller
var app = angular.module('callapp', []);
app.controller('eController', function($scope, $http, $log) {
$scope.urlString = []; //this is filled with values
for( var i=0; i<3; ++i)
{
var currentURL = $scope.urlString[i];
$http.get(currentURL)
.success( function(response) {
//how do I access currentURL here?
$log.info(this.currURL) //this is printing "undefined"
});
}
The urls are generated dynamically, and I have to get data from these urls. The urls are generated before the for loop executes (and the url requests are asynchronous).
I tried $.ajax(currentURL) instead of $http.get method, but I got the same result - "undefined".
Is there any way I can access the currentURL and the current value of 'i' inside the .success(function ())?