so far I had no more problems and thought I could handle AngularJS a bit.
But now I tried to return a value without any results.
The third line calls my function to fetch a name from the database. But that function doesn't return the result.
$scope.showModal = function ($event,listId) {
console.log("showModal: "+$event.type+" - id: "+listId);
console.log("scope.listname: "+getListname(listId));
$('#edit').modal('toggle');
};
function getListname(listId) {
var query = 'SELECT name FROM Lists WHERE id=(?)';
$scope.db.transaction(
function (transaction) {
transaction.executeSql(query, [listId],
function (tx, results) {
// console.log("Result: "+results.rows.item(0).name); // works!
return results.rows.item(0).name; // returns nothing or not to the sender
}
);
}
);
}
If I use console.log() within executeSql I get a value in the console. But why can't I get my result back to the calling function?