I have four dynamically inputs. User select how many wants. In input he enter article ID and on success I send this in URL. Url can have only two or three or four id
'http://someurl/' + ID + '/someParams'
example: 'http://someurl/991,992,993,994/someParams'
I pass ID's from html to controller
$scope.submitChoice = function (name) {
$scope.choices.forEach(function(choice, index){
if(choice.name)
{
switch (index) {
case 0:
var firstId = choice.name;
break;
case 1:
var secondId = choice.name;
break;
case 2:
var thirdId = choice.name;
break;
case 3:
var fourthId = choice.name;
break;
}
console.log(firstId, secondId, thirdId, fourthId);
$scope.getBenchIdForCompare(firstId, secondId, thirdId,fourthId);
}
})
}
I use SWITCH CASE and INDEX because I need every of this ID set to unique var (because of another part of my app).
Problem is, when I submit entered ID in input, I get this in my console when I
console.log(firstId, secondId, thirdId, fourthId);
console
991 undefined undefined undefined
undefined 992 undefined undefined
undefined undefined 993 undefined
undefined undefined undefined 994
And I can not pass this to another function because I need to have 991 992 993 994
Is there another way to make this?
forloop as well as moveconsole.logand function$scope.getBenchIdForComparecall outsideforloop.$scope.variable_names