2016-11-09 215 views
0

我想将DeepLinking添加到我的混合应用程序,我发现它适用于离子本机。
我有一个在iOS和Android上测试的SQLite数据库的工作项目,但是当我在应用程序模块中包含ionic.native时,它会引发错误。
科尔多瓦SQLite与角1中的离子本机

app.module:angular.module('myApp', ['ionic', 'ionic.native'])
app.run:openDB是app.js:207
ionic.Platform.ready(function() { db = $cordovaSQLite.openDB({name: 'my.db', location: 'default'}); });

Error: Uncaught TypeError: undefined is not a function. app.js:207

The blog post about ionic deep linking I try to put into practice
Ionic deep linking plugin docs for Ionic/Angular 1

我想这是与离子相关-native的插件列表,因为它也有SQLite。

+0

你能告诉您更多的代码,尤其是依赖注入的一部分吗?在你的情况下,这可能是'run()'函数。 – Dexter

+0

当然,我所做的只是添加'ionic.native'到模块中。在此之前,一切工作正常。 '.run(函数($ window,$ ionicPlatform,$ rootScope,$ state,$ cordovaSQLite,$ ionicPopup,$ ionicHistory){...}'和一些服务也包括在内。 – MagicDragon

+0

尝试在'deviceready'事件中使用openDB –

回答

0

我可以通过改变打开数据库的方式来解决问题。在我执行cordova时,SQLite数据库在window.sqlitePlugin.openDatabase()的iOS上遇到了问题,但是没有使用ionic.native,所以使用$cordovaSQLite.openDB()解决了我的问题,因为它直接调用插件。

我现在开的DB方式:
ionic.Platform.ready(function() { db = window.sqlitePlugin.openDatabase({name: 'qpi.db', location: 'default'}); });