i am new to ionic framework and promises, this is part of my factory, Productos
....
},
getCombinations: function(productId) {
var resultt = [];
var promises = [];
url_to = 'http://example.com/api/combinations?display=full&filter[id_product]=' + productId;
$http({method: 'GET', url: url_to })
.then(function(response) {
results = x2js.xml_str2json(response.data);
angular.forEach(results.prestashop.combinations.combination, function(val, key) {
var deferred = $q.defer();
url_to = 'http://example.com/api/product_option_values?display=[name,color]' + '&filter[id]=[' + val.associations.pr
oduct_option_values.product_option_value[0].id + '|' + val.associations.product_option_values.product_option_value[1].id + ']';
$http({method: 'GET', url: url_to }).then(function(response) {
results = x2js.xml_str2json(response.data);
resultt.push({ 'size': results.prestashop.product_option_values.product_option_value[0].name.la
nguage.__cdata, 'color_hex': results.prestashop.product_option_values.product_option_value[1].color.__cdata, 'color_name': results.pres
tashop.product_option_values.product_option_value[1].name.language.__cdata});
deferred.resolve(resultt);
})
promises.push(deferred);
});
}, function(response) {
return $q.reject(response.data);
//something went wrong
});
return $q.all(promises);
},
....
and in my controller
...
Productos.getCombinations(productId)
.then(function(data) {
console.log('getcombinations');
console.log(data);
...
but my data is empty, could someone help me out, thanks in advance.