未捕获的TypeError:无法读取未定义的属性“openDatabase”

时间:2016-09-22 17:09:57

标签: angularjs sqlite ionic-framework sql-server-2012-localdb

我想第一次使用带有cordova框架的sqlite。正如我在教程中读到的那样,我应该像这样使用ngcordova:

  if (window.cordova)
     {
     db = $cordovaSQLite.openDB({ name: "littlebird.db" }); //device
     }
    else
     {
            db = window.openDatabase("littlebird.db", '1', 'littlebird', 1024 * 1024 * 100); // browser
     }

        $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS mobileContact (id integer primary key, name text, mobile text,exit integer)");

但在部署时面临问题

Uncaught TypeError: Cannot read property 'openDatabase' of undefined ng-cordova.min.js (9,20659)

1 个答案:

答案 0 :(得分:0)

编辑:

指定位置解决问题:

db = $ cordovaSQLite.openDB({name:“DBname.db”,location:'?'});

(请查看此答案帖子的评论以获取更多详细信息。)