JavaScript Array Format

0

PROBLEM

I have a problem returning the results of a query, since I need to sort the results of a query in a single array in JavaScript, and not a array with its objects, each object being a different array.

CODE

$scope.tableDatos= datosObtenidos.data;
      var countRegistro = [];
      $scope.tableDatos.forEach(function(registro, index) 
      {
          countRegistro.push([registro.Registros]);
      });
      console.log("Registro: ", countRegistro);

RESULT OBTAINED

EXPECTED RESULT

  

Note: The expected data I did with a simple array that was   declared with that order.

$scope.datos = [
        ["1", "3118"]
      ];
    
asked by jecorrales 19.02.2018 в 21:50
source

1 answer

3

Remove the brackets when pushing and the friend problem is solved =)

$scope.tableDatos= datosObtenidos.data;
  var countRegistro = [];
  $scope.tableDatos.forEach(function(registro, index) 
  {
      countRegistro.push(registro.Registros);
  });
  console.log("Registro: ", countRegistro);
    
answered by 19.02.2018 / 22:12
source