0

I am still working on my first ionic app, and again I am stuck with a problem:

My app uses SQLite to store data. I use the sqlite-plugin from ngCordova and the cordova-sqlite-storage plugin from litehelpers.

If I test the app with 'ionic serve --lab' everything works fine. No errors, the database is there, the data is ok...

But if I go and test it on an Android device 'ionic run android -l -c -s' I get the following error, and the application freezes:

0     779681   error    TypeError: Cannot read property 'transaction' of undefined
    at Object.execute (http://192.168.1.14:8100/lib/ngCordova/dist/ng-cordova.js:6872:11)
    at new <anonymous> (http://192.168.1.14:8100/js/controllers.js:284:18)
    at Object.instantiate (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:18010:14)
    at $controller (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:23412:28)
    at self.appendViewElement (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:59900:24)
    at Object.switcher.render (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:57893:41)
    at Object.switcher.init (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:57813:20)
    at self.render (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:59759:14)
    at self.register (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:59717:10)
    at updateView (http://192.168.1.14:8100/lib/ionic/js/ionic.bundle.js:65398:23)

My app has 4 pages, and works with the ui-router. Every page has it's own controller.

I am searching and trying since two weeks, but no chance...

Any hints?

Thanks, Christian.

1 Answer 1

1

I found the problem: loading the database on the device takes longer, and out of the box Ionic (-> AngularJS -> JavaScript) doesn't wait for task.

So I had to use promises:

Now It works...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.