title: Retrieving data from MySQL with AngularJS and NodeJS
body: <p>first of all, perhaps I need to clarify that I'm new with this kind of technologies. I'm migrating from PHP to JavaScript and I've never made this kind of work before. I'm making a desktop app with Electron + AngularJS. I have a simple table where I need to show the fetched MySQL table data. Looking information I found a simple way to do it with NodeJS, but I have problems storing de retrieved data to the $scope to after, show that with the ng-repeat directive. This my code (simplyfied):</p>
  
  <pre><code>app.controller('registrosController', function($scope, $http) {
      var mysql = require('mysql');
      var connection = mysql.createConnection({
          host: 'localhost',
          user: 'root',
          password: null,
          database: 'dniscan'
      })
      connection.connect((err) =&gt; {
          if(err){
              return console.log(err.stack);
          }
      })
      $queryString = 'SELECT * FROM registros ORDER BY escaneado DESC';
      connection.query($queryString, (err, data) =&gt; {
          if(err) {
              return console.log("Ocurrió un error durante la consulta", err)
          }
          console.log(data)       //The data shows correctly in the console.
          $scope.registros = data //This not working. It returns undefined.
      });
      connection.end();
  });
  </code></pre>