TypeError: Cannot read property 'openDatabase' of undefined

前端 未结 2 1745
青春惊慌失措
青春惊慌失措 2020-12-30 08:22

I want to work with sqlite with cordova framework for the first time. As I\'ve read on a tutorial I should use ngcordova like this:

var db = null;
app.contro         


        
相关标签:
2条回答
  • 2020-12-30 09:03

    You might take a look at this tutorial:

    https://www.thepolyglotdeveloper.com/2014/11/use-sqlite-instead-local-storage-ionic-framework/

    When you see this error:

    TypeError: Cannot read property 'openDatabase' of undefined

    It is happening for one of a few reasons:

    1. You are not wrapping the $cordovaSQLite methods in the $ionicPlatform.ready() function.
    2. You are trying to test this native plugin from a web browser.
    3. You have not actually installed the base SQLite plugin into your project.

    The most common reasons for this error are #1 and #2. Native plugins, must be used only after the application is confirmed ready, thus the $ionicPlatform.ready() method. Since native plugins use native code, you cannot test them from your web browser.

    Read through the tutorial I linked because it should help you.

    Regards,

    0 讨论(0)
  • 2020-12-30 09:17

    Actually, I opened an old project and I get this error only when I run the project with -cls (because of liverelaod). But I have a small bug to fix there so I didn't investigate it too much(just fix it without livereload). But maybe this little hint helps somebody.

    0 讨论(0)
提交回复
热议问题