mardi 29 mars 2016

Angular callback function preventing result to be displayed out of its function

When i run this script, it display 0 instead of the value from qty column in sales table. I want it to display the value from the qty column which is 20.

 $scope.wremain=0;
     var query = "SELECT * FROM sales WHERE buy_id=2";
     $cordovaSQLite.execute(db, query, []).then(function(success) {
        $scope.wremain=success.rows.item(0).qty;
 }, function (error) {alert("Error retrieving value");});

 alert($scope.wremain);

I will be grateful for any suggestion that will assist me achieve my goal. Thank you for your time in advance

Aucun commentaire:

Enregistrer un commentaire