Here is the code snippet of my controller:
var app = angular.module('callapp', []);
app.controller('eController', function($scope, $http, $log) {
$scope.urlString = []; //these values are populated
for( var i=0; i<3; ++i)
{
var currentURL = $scope.urlString[i];
$http.get(currentURL)
.success( function(response) {
//how can I access currentURL here?
$log.info(this.currURL) //this prints "undefined"
});
}
The URLs are dynamically generated before the loop executes. Data needs to be fetched from these URLs which are sent as asynchronous requests.
I attempted using $.ajax(currentURL) instead of $http.get method, but encountered the same issue - "undefined".
Is there a possible way to access both the currentURL and the 'i' value inside the .success(function ())?