Q:

Modify list of objects via WebService, how to get final Value List?

I get data from a web service, I need to send this data to another service to modify some values, so when I get the data there are more async calls to make. I don't know how to get the final values.
What I want to call:
SomeService.getSomething(id).then(function(something) {
    SomeOtherService.addXToDatas(something.data).then(function(fixedData) {
        $scope.data = fixedData;
    });
});

What I have:
    someOtherService.addXToDatas = function(datas) {
        datas.forEach(function(value, index, array) {
            getSomethingFromApi(value.something).then(function(bla) {
                array[index] = bla;
            });

        });
    }

    someOtherService.addXToData = function(data) {
            getSomethingFromApi(data.something).success(function(response) {
                order.someMore = response.data;
            });
        }           
    }

Unfortunately I have no actual clue how to accomplish this in javascript. 
For a single object I could use a callback, but for a list of objects?

A:

Angular.js has build-in implementation of Q, so you could use promise combination Q.all. It takes array of promises and returns a promise that is fulfilled when all other promises are.
You can easily create array of promises with Your code using .map instead of .forEach:
someOtherService.addXToDatas = function(datas) {
    return $q.all( datas.map(function(value, index, array) {
            return getSomethingFromApi(value.something).then(function(bla) {
                array[index] = bla;
            });

        })).then(function() {
            return datas;
        });
}

SomeOtherService.addXToDatas(something.data).then(function(fixedData) {
    $scope.data = fixedData;
});

Explanation:

datas.map() creates an array of promises. API calls themselves will be executed asynchronously.
$q.all() returns a promise which is fulfilled when all promises passed to it from (1) are fulfilled.
Final then returns modified data array. It is called after all promises from (1) are fulfilled and all modifications of data are made.

