Resolve a SQLite call in ui-router

I am trying to load data from my SQLite DB before loading my view by using resolve when defining my state.

Currently

.state("menu", {
    templateUrl: "templates/menu.html",
    controller: "MenuCtrl",
    url: "/menu",
    resolve:{
         simpleObj:  function(){
            return {value: 'simple!'};
         },
         promiseObj:  function($cordovaSQLite){
            query = "SELECT id FROM reports WHERE progress_status<2";
            $cordovaSQLite.execute(db, query, []).then(function(res) {                  
              var pendingList = [];
              for (var i = 0; i < res.rows.length; i++) {
                 pendingList.push(res.rows.item(i).id);
              }
              return pendingList;
            });
         }
      }

})

But this code gives me an infinite digest loop.

I normally have the DB execute code in a service (giving same result) but have moved inline for testing sake

Can anyone tell me how I might do this properly?

This will solve your issue

Put the following in your index. this will bootsrap your angular app regardless of whether or not you are on a device or browser, but will guarantee that cordova is loaded on device

 (function (window, document, angular) {
   'use strict';

   window.ionic.Platform.ready(function () {
     angular.bootstrap(document, ['yourAppModule']);
   });
 }(window, document, angular));

you need to return the promise from the call… not sure what these other answers are about, unless I dont understand the question; but when using resolve this way you definitely need a promise.

.state("menu", {
    templateUrl: "templates/menu.html",
    controller: "MenuCtrl",
    url: "/menu",
    resolve:{
         simpleObj:  function(){
            return {value: 'simple!'};
         },
         promiseObj:  function($cordovaSQLite){
            query = "SELECT id FROM reports WHERE progress_status<2";
            return $cordovaSQLite.execute(db, query, []).then(function(res) {                  
              var pendingList = [];
              for (var i = 0; i < res.rows.length; i++) {
                 pendingList.push(res.rows.item(i).id);
              }
              return pendingList;
            });
         }
      }

})