I'm not a veteran of JavaScript and I have a little problem :
In an AngularJS controller, I get 2 arrays from a WebService of the form [{"id":"1", "name":"aname1"}, {"id":"2", "name":"aname2"}]. They have both the same structure (this shouldn't be important).
With concat() or push() I'm unable to merge these arrays together, and I don't understand why.
I tried
var arrayS = Service.list(); // Get data from WebService
var arrayAE = ActeurExterne.list(); // Idem
var arrayRes = arrayS.concat(arrayAE);
$scope.acteurs = arrayRes;
In my AngularJS app, the array acteurs is empty (if I displays it outside a ng-repeat loop, it displays [] while arrayS and arrayAE display their contents)
And the same logic with :
array1.push.apply(array1, array2);
I tried to push elements of array2 one by one in a for loop, same result.
Nothing worked. Why?
array1.push.apply(array1, array2);is working for me.concatis also working, though it return a new array:array1 = array1.concat(array2);.concatorpushdoesn't work? Please state what is the problem with a code fragment... for sure your problem is somewhere else.