As it has been mentioned your http requests are all kicked off simultaneously and the resolve at different times because of that. The similest solution would be to make the http requests synchronously, however that is unrealistic but there is a way to wait for all of the async calls to complete then process them.
Promises to the rescue!
Using promises you can kick off all of your http requests but wait for them to complete before processing them. This will change the output of the code to be a promise though so what ever is calling this will need to be changed to use the returned promise.
var getRadioShows = function() {
// Create a promise that will resolve when all results have been compiled.
var deferredResults = $q.defer();
// Create an array that will store all of the promises
// for the async http requests
$http.get('http://api.example.com/radios/').success(function(results) {
var deferredHttpCalls = [];
for (i = 0; i <= results.length; i++) {
var deferredRequest = $q.defer();
$http.get('http://api.example.com/radioshows/fr/radio/' + results[i].id + '/?day=' + x + '').success(function(resultShows) {
if (resultShows.success === false) {
// I am guessing this is not a failure case.
// If it is then you can call deferredRequest.reject('Request was not successful');
deferredRequest.resolve();
} else {
deferredRequest.resolve(resultShows);
}
}).error(function() {
// reject this request and will also cause
// deferredResults to be rejected.
deferredRequest.reject(err);
});
// Gather all of the requests.
deferredHttpCalls.push(deferredRequest);
}
// Wait for all of the promises to be resolved.
$q.all(deferredHttpCalls).then(function(results) {
// 'results' is an array of all of the values returned from .resolve()
// The values are in the same order and the deferredHttpCalled array.
// resolve the primary promise with the array of results.
deferredResults.resolve(results);
});
}).error(function(err) {
// reject the promise for all of the results.
deferredResults.reject(err);
});
return deferredResults;
}
Then you would used the call that returns the promise like so.
getRadioShows().then(
// success function, results from .resolve
function(results) {
// process results
},
// error function, results from .reject
function(err) {
// handle error
}
)
For more information regarding how $q, and all Promise/A+ libraries work, see the Promise/A+ standard here: https://promisesaplus.com/