0
I need to pass an array object as follows, to the api:
[paulo = 1, gustavo = 2, amanda = 3,...]
I have the following code:
$scope.salvarHabilidades = function(pro){
var valores = pro.filter(function(o,i){
return o.habilidades == true;
});
var habi = new Array();
for(var i = 0; i < valores.length; i++){
console.log(valores[i]);
habi = [(valores[i].descricao = valores[i].idhabilidade)];
}
habi.idusuario = $rootScope.idPro;
console.log(habi);
}
For what appears in the console line "console.log(values[i])" is this:
Follow the selection screen:
[paulo = 1, gustavo = 2, amanda = 3,...]
is not a valid array, each input will get the value of the assignment. It was not clear to me the format you need..– BrTkCa
The @Lucascosta is right. This: [paulo = 1, Gustavo = 2, Amanda = 3,...] is not an object notation and much less an array notation. The closest you could get to an array notation would be: ["paulo = 1", "Gustavo = 2", "Amanda = 3",...]. But that’s definitely not what you want!
– alan
I need the number to be assigned to the name. It may be that the example I gave is not a valid array, but I need to mount in a way that is. They understood?
– GustavoSevero
Let it be ["paul" = 1, "Gustav" = 2, ...]
– GustavoSevero
A legal structure would be [ {"name": "paul", "value": 1}] for me
– BrTkCa
Could you clarify your question a little, Gustavo? for example: What are numerical values? Skills Ids? If so, a person could own 2 or more?
– OnoSendai
Yes, this @Lucascosta! .
– GustavoSevero
@Gustavosevero And what would be the relationship with skills?
– OnoSendai
In place of the name go skills, @Onosendai.
– GustavoSevero