ionic + sqlite在浏览器中工作但在真实设备上有TypeError

时间:2016-08-03 12:43:16

标签: javascript angularjs sqlite cordova ionic-framework

我仍在使用我的第一个离子应用程序,而且我遇到了一个问题:

我的应用使用SQLite存储数据。我使用ngCordova的sqlite-plugin和litehelpers的cordova-sqlite-storage插件。

如果我使用'ionic serve --lab'测试应用程序,一切正常。没有错误,数据库在那里,数据还可以......

但是,如果我在Android设备上测试它'离子运行android -l -c -s',我会收到以下错误,应用程序会冻结:

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)

我的应用有4页,可与ui-router配合使用。每个页面都有自己的控制器。

我正在寻找和尝试两周,但没有机会...

任何提示?

谢谢, 基督教。

1 个答案:

答案 0 :(得分:1)

我发现了问题:在设备上加载数据库需要更长的时间,开箱即用的Ionic( - &gt; AngularJS - &gt; JavaScript)不会等待任务。

所以我不得不使用承诺:

现在它有效......

相关问题