My code receives several url from a request, I wish to insert each in an array and then forward to another part of code that depends on this url array (contatosSalvos.promise.then....)
The element that I'm inserting is valid and exists, I don't get any errors.
But when I get my URL array it comes with null values. My URL array is contatosUri. Can anyone help me why this happens?
deferred.promise.then(function (resolve){
for(var i = 0; i < $scope.contatos.length; i++){
$scope.contatos[i].agencia = resolve[i].data._links.self.href;
salvarContatos.push(contatosAPI.postContato($scope.contatos[i]));
}
$q.all(salvarContatos).then(function (values){
var i = 0;
while(i < values.length){
contatosUri.push(values[i].data._links.self_href);
i++;
if(i == values.length){
contatosSalvos.resolve(contatosUri);
}
}
}).catch(function (error){
alert("Opsss\nOcorreu um erro ao salvar os contatos");
console.log("Erro ao salvar contatos" + JSON.stringify(error));
});
});