Retrieving data from sqlite using angular is not displaying/rendering the data as expected

I'm currently working on a mobile application using PhoneGap and Angular.js, utilizing SQLite for local data storage. However, I've encountered an issue with rendering asynchronous data retrieved from SQLite. The problem lies in the fact that the data is not being displayed/rendered properly despite trying to use the $apply method.

Here's a snippet of my code:

function ProjectListCtrl($scope) {
    $scope.test = function(){
        db.transaction(queryDB, errorCB);

        var test1 = function(db_result){
            $scope.projects = db_result;
            $scope.$apply(function(){ //trying to update the scope
                $scope.projects = db_result;
            });

            console.log($scope.projects)
        }
        var make_result = function (tx, results, $scope) {
            querySuccess(tx, results, $scope,test1 );
        };

        function querySuccess(tx, results, $scope, callback) {
            var len = results.rows.length;
            var db_result = [];
            for (var i=0; i<len; i++){
                db_result[i] = results.rows.item(i);
            }
              callback(db_result)
        };

        function queryDB(tx) {
            tx.executeSql('SELECT * FROM Projects', [], make_result, errorCB);
        }
    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue component functions failing to execute

I've recently started exploring Vue and encountered an issue with a component's "mounted" method not triggering. Despite thorough checks for errors or warnings, and reviewing the code multiple times, I can't seem to pinpoint the problem. Str ...

JavaScript debugging causing system freeze

Currently, I am working on a project that involves using MVC and dropdown lists. My issue arises when the dropdown list changes, as there is some javascript code that needs to execute. To troubleshoot the problem of the system locking up every time I tried ...

Tips for retrieving information from a web endpoint using Angular

My task involves utilizing Angular to retrieve data from a web endpoint and display it to the user. The setup requires configuration through bower and the use of grunt as a task manager. I have already installed bower, Angular, and Bootstrap, with the pag ...

Ways to troubleshoot setTimeout functioning during HTTP requests?

Utilizing Socket IO in my client app, I have implemented a feature to check for unread events. The process involves making a request to the backend, which then sets a 5-second timeout before checking for any new events and sending them back. // client soc ...

Enhance ant design modal functionality by enabling resizing capabilities

I'm experiencing an issue with the Ant Design Modal component as it does not support resizing the modal window. I'm looking for a way to enable manual resizing of the modal window once it has been opened. Is there a solution available for this fu ...

`sails js: accessing external domain for static file loading`

I'm currently using SailsJS on the server side and AngularJs on the client side. Both the client and server are located on different domains. I have enabled CORS in SailsJS and configured Restangular like this: RestangularProvider.setBaseUrl('U ...

Is it possible for a function to alter the 'this' object in JavaScript?

Referencing the MDN article on this keyword in JavaScript When not in strict mode, 'this' in a function will point to the global object. However, attempting to modify a global variable within a function does not result as expected. Is there an ...

Proper method for incorporating loading and error messages with the help of useContext and react hooks

Currently, I have a context.js file that makes an ajax call and stores the data in an array to be shared across components. While adding some 'loading ...' text during the loading process using axios, I feel there might be a better way to handle ...

Tips for styling my date using MomentJS

I am currently using moment.js for displaying dates in my application. The date format is determined based on the locale stored in the variable clientLanguage. I have tried various approaches, including the following: moment(myISODate).locale(clientLang ...

Modify the transition and design of two progress bars

I'm having an issue with merging two Bootstrap progress bars into one. Initially, the first progress bar appears when the page loads and hides after data is loaded. At the same time, the second progress bar shows up. However, the transition animation ...

Implementing jQuery autocomplete on dynamically generated fields post page load

I have successfully implemented jQuery UI Autocomplete to fetch data from a DB and populate a form dropdown. However, I am faced with the challenge of adding more form fields dynamically that also need to have the autocomplete feature applied to them. Is ...

Utilizing objects as tags within the Form Tags component in Bootstrap Vue

Let's break down the following code snippet from the documentation: <template> <div> <b-form-tags v-model="value" no-outer-focus class="mb-2"> <template v-slot="{ tags, inputAttrs, inputHandlers, addTag, removeTag }"> ...

Tips for implementing two Secondary Actions in React Material UI, with one positioned on the left corner and the other on the right, while ensuring that the behavior of the

Is there a way to display two secondary actions on either end of a list item without triggering additional onclick events? The placement can be adjusted by overriding the CSS properties right and left. https://i.stack.imgur.com/rhr7N.gif The issue arises ...

The warning message "UnhandledPromiseRejectionWarning: Error: ENOENT: unable to locate the specified file or directory" was triggered due to the absence of the file "level

Currently, I am working on a project involving a popular application called Discord. My main task is to code a bot that can send images from a local file source. The bot is hosted on Heroku, which means all the files are stored in the cloud and maintained ...

What is the best way to incorporate various styles into one :style attribute?

Within my vuetify project, I encountered a challenge of adding multiple styles to the same style attribute. Specifically, I have successfully implemented a vuetify breakpoint and now wish to include {backgroundColor:'Color'} within the existing a ...

Ways to activate an event with select2

Hey there! I have a unique setup on my selling item page with select tags. The first select tag is created using HTML, while the others are dynamically added using jQuery when the user clicks on an "Add More" button. <select id='code0' onclic ...

Utilize jQuery to compare JavaScript files between the cache and the application

When making changes to my JS files in the application, I find myself constantly having to clear my browser's cache to see those changes. To avoid this inconvenience, I tried using the following: <script type="text/javascript" src="js/main.js?cache ...

Guide on how to enable the first dropdown menu item upon clicking in Bootstrap 5

I am using Bootstrap 5 dropdowns and have defined them as follows: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4a2825253e393e382b3a0a7f647b">[email protected]</a>/ ...

Unable to remove any even numbers from my array

Having trouble removing all the even numbers from this array. Can't seem to get them all out of there, not sure why. var numArr = [3,45,56,7,88,56,34,345]; for (var i = 0; i < numArr.length; i++) { if (numArr[i] % 2 === 0) { ...

Exploring the Mystery of why Three.js Fails to Apply Textures to Objects

I'm attempting to add a texture to an object with the following code: <html> <head> <title>My first Three.js app</title> <style> body { margin: 0; } canvas { width: 100%; h ...