I make a simple project of sqlite and run on ios .when I check on chrome I am able to insert data on db .but when I check on ios it give this error
2015-04-09 19:55:40.761 todo[7533:98283] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/naveenkumar/Library/Developer/CoreSimulator/Devices/A028C587-19F4-4C5E-81DB-95A0564F8A1B/data/Containers/Data/Application/16224058-B5A0-45EF-AE31-7F055429B18B/Library/Cookies/Cookies.binarycookies
2015-04-09 19:55:40.895 todo[7533:98283] Apache Cordova native platform version 3.8.0 is starting.
2015-04-09 19:55:40.895 todo[7533:98283] Multi-tasking -> Device: YES, App: YES
2015-04-09 19:55:40.897 todo[7533:98283] Unlimited access to network resources
2015-04-09 19:55:41.154 todo[7533:98283] [CDVTimer][keyboard] 0.057995ms
2015-04-09 19:55:41.154 todo[7533:98283] [CDVTimer][TotalPluginStartup] 0.238001ms
2015-04-09 19:55:41.210 todo[7533:98283] Resetting plugins due to page load.
2015-04-09 19:55:41.414 todo[7533:98283] Finished load of: file:///Users/naveenkumar/Library/Developer/CoreSimulator/Devices/A028C587-19F4-4C5E-81DB-95A0564F8A1B/data/Containers/Bundle/Application/FCBFA674-B22F-4DDB-9FD1-37B05A3351FC/todo.app/www/index.html
2015-04-09 19:55:41.483 todo[7533:98283] Initializing SQLitePlugin
2015-04-09 19:55:41.483 todo[7533:98283] Detected docs path: /Users/naveenkumar/Library/Developer/CoreSimulator/Devices/A028C587-19F4-4C5E-81DB-95A0564F8A1B/data/Containers/Data/Application/16224058-B5A0-45EF-AE31-7F055429B18B/Documents
2015-04-09 19:55:41.484 todo[7533:98283] Detected Library path: /Users/naveenkumar/Library/Developer/CoreSimulator/Devices/A028C587-19F4-4C5E-81DB-95A0564F8A1B/data/Containers/Data/Application/16224058-B5A0-45EF-AE31-7F055429B18B/Library
2015-04-09 19:55:41.484 todo[7533:98283] no cloud sync at path: /Users/naveenkumar/Library/Developer/CoreSimulator/Devices/A028C587-19F4-4C5E-81DB-95A0564F8A1B/data/Containers/Data/Application/16224058-B5A0-45EF-AE31-7F055429B18B/Library/LocalDatabase
2015-04-09 19:55:41.484 todo[7533:98283] -[__NSDictionaryM length]: unrecognized selector sent to instance 0x7f9010da9520
2015-04-09 19:55:41.485 todo[7533:98283] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> -[__NSDictionaryM length]: unrecognized selector sent to instance 0x7f9010da9520
here is my code . HTML file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter" ng-controller="ExampleController ">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Start</h1>
</ion-header-bar>
<ion-content>
<button class="button" ng-click="insert('Brian', 'Mendes')">Insert</button>
<button class="button" ng-click="select('Mendes')">Select</button>
<!--button ng-click="insert('naveen','sharma')">insert</button>
<button ng-click="select('sharma')">select</button-->
</ion-content>
</ion-pane>
</body>
</html>
app.js
var db = null;
var example = angular.module('starter', ['ionic', 'ngCordova'])
.run(function($ionicPlatform, $cordovaSQLite) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
db = $cordovaSQLite.openDB({ name: "my.db" });
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)");
});
})
example.controller("ExampleController", function($scope, $cordovaSQLite) {
$scope.insert = function(firstname, lastname) {
var query = "INSERT INTO people (firstname, lastname) VALUES (?,?)";
$cordovaSQLite.execute(db, query, [firstname, lastname]).then(function(res) {
var message = "INSERT ID -> " + res.insertId;
console.log(message);
alert("naveen")
alert(message);
}, function (err) {
console.error(err);
alert(err);
alert("error")
});
}
$scope.select = function(lastname) {
var query = "SELECT firstname, lastname FROM people WHERE lastname = ?";
$cordovaSQLite.execute(db, query, [lastname]).then(function(res) {
if(res.rows.length > 0) {
var message = "SELECTED -> " + res.rows.item(0).firstname + " " + res.rows.item(0).lastname;
alert(message);
console.log(message);
alert("select")
} else {
alert("No results found");
console.log("No results found");
}
}, function (err) {
alert(err);
console.error(err);
});
}
});
Actually I did not get any alert when i click insert or select .I make simple blank ionic project . follow these links https://blog.nraboy.com/2014/11/use-sqlite-instead-local-storage-ionic-framework/ http://ngcordova.com/docs/plugins/sqlite/
But I didnot find any console and alert when I click on insert and select button