angularjs - $cordovaSQLite.execute is not a function in ionic -


in code $cordovasqlite.execute function works in .run function gives me error in controller . don't know doing wrong , have included required plugin , follow step of example https://blog.nraboy.com/2014/11/use-sqlite-instead-local-storage-ionic-framework/

 var db = null;     var myapp=angular.module('starter', ['ionic','btford.socket-io','logincntrl','slidecntrl','app','chatcntrl','ngcordova','ngcordova.plugins.sqlite'])  .run(function($ionicplatform,$cordovasqlite) {     $ionicplatform.ready(function() {          // hide accessory bar default (remove show accessory bar above keyboard         // form inputs)         if(window.cordova && window.cordova.plugins.keyboard) {             cordova.plugins.keyboard.hidekeyboardaccessorybar(true);         }         if(window.statusbar) {             statusbar.styledefault();         }         console.log("the application resuming background");         db = $cordovasqlite.opendb({ name: app_db_name });         $cordovasqlite.execute(db, "create table if not exists people (id integer primary key, firstname text, lastname text)");          var query = "select firstname, lastname people lastname = ?";         $cordovasqlite.execute(db, query, ["pruthvi"]).then(function(result) {             if(result.rows.length > 0) {                 console.log("selected -> " + result.rows.item(0).firstname + " " + result.rows.item(0).lastname);                 alert("selected -> "+ result.rows.item(0).firstname + " " + result.rows.item(0).lastname)             } else {                 console.log("no results found");             }         }, function (err) {             console.error(err);         });         //  $cordovasqlite.execute(db, "create table if not exists "+ app_db_table_login_name +"(id integer primary key, login_username text, login_password text)");         console.log("success");     }); });   myapp.controller('indexcontroller', ['$scope','$rootscope', function($scope,$rootscope,$cordovasqlite, $ionicplatform){     var query = "select firstname, lastname people lastname = ?";     $cordovasqlite.execute(db, query, ["pruthvi"]).then(function(result) {         if(result.rows.length > 0) {             console.log("selected -> " + result.rows.item(0).firstname + " " + result.rows.item(0).lastname);             alert("selected -> "+ result.rows.item(0).firstname + " " + result.rows.item(0).lastname)         } else {             console.log("no results found");         }     }, function (err) {         console.error(err);     }); }]); 

typeerror: $cordovasqlite.execute not function @ new (app.js:105) @ object.invoke (ionic.bundle.js:13277) @ extend.instance (ionic.bundle.js:17826) @ nodelinkfn (ionic.bundle.js:16936) @ compositelinkfn (ionic.bundle.js:16368) @ compositelinkfn (ionic.bundle.js:16372) @ publiclinkfn (ionic.bundle.js:16243) @ ionic.bundle.js:10462 @ scope.$eval (ionic.bundle.js:24673) @ scope.$apply (ionic.bundle.js:24772)(anonymous function) @ ionic.bundle.js:21157 console-via-logger.js:173 no content-security-policy meta tag found. please add 1 when using cordova-plugin-whitelist plugin.(anonymous function) @ console-via-logger.js:173 console-via-logger.js:173 application resuming background console-via-logger.js:173 open database: db_demoionic.db 2console-via-logger.js:173 new transaction waiting open operation console-via-logger.js:173 success console-via-logger.js:173 db opened: db_demoionic.db console-via-logger.js:173 no results found console-via-logger.js:173 no content-security-policy meta tag found. please add 1 when using cordova-plugin-whitelist plugin. 3console-via-logger.js:173 no content-security-policy meta tag found. please add 1 when using cordova-plugin-whitelist plugin.

it looks code in myapp.controller(...) call executed upon startup. if controller connected page body has wait until ionic/ngcordova ready (using $ionicplatform.ready(...) example).


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -