Thứ Tư, 18 tháng 3, 2015

Hybrid app - Connect to local database by SQLite

Hybrid app - Connect to local database by SQLite


---o0o---


Original link
  1. Install the sqlite plugin
  2. Add ngCordova
  3. Add SQLitePlugin.js file

1. Install the sqlite plugin

Run command:

ionic plugin add https://github.com/brodysoft/Cordova-SQLitePlugin

When done, in plugins folder add new folder names com.brodysoft.sqlitePlugin

2. Add ngCordova

Download the zip file here

Extract file and put ng-cordova-master\dist\ng-cordova.js or ng-cordova-master\dist\ng-cordova.min.js file in your folder such as www\js

Include ng-cordova.js or ng-cordova.min.js in your index.html file before cordova.js and after your AngularJS / Ionic file (since ngCordova depends on AngularJS).

    
<script src="js/ng-cordova.js"></script>
<script src="cordova.js"></script>
   

3. Add SQLitePlugin.js file

Go https://github.com/brodysoft/Cordova-SQLitePlugin and clone code

Copy SQLitePlugin.js file from Cordova-SQLitePlugin\www folder to in your folder such as www\js

Include SQLitePlugin.js file in your index.html file before everything

    
<script src="js/SQLitePlugin.js"></script>
<script src="lib/ionic/js/ionic.bundle.js">></script>
<script src="js/ng-cordova.js"></script>
<script src="cordova.js"></script>
   

Done, now you can run

  • ionic build
  • ionic run

Không có nhận xét nào:

Đăng nhận xét