Angularjs $cordovaSQLite.execute不是函数

Angularjs $cordovaSQLite.execute不是函数,angularjs,sqlite,ionic-framework,Angularjs,Sqlite,Ionic Framework,我对爱奥尼亚一号还不熟悉。我想通过表单将数据插入sqlite表。但当我单击“提交”按钮时,它显示以下错误: TypeError: $cordovaSQLite.execute is not a function at ChildScope.$scope.insertNewItem (addnewitemCtrl.js:12) at fn (eval at compile (ionic.bundle.js:27643), <anonymous>:4:230) a

我对爱奥尼亚一号还不熟悉。我想通过表单将数据插入sqlite表。但当我单击“提交”按钮时,它显示以下错误:

TypeError: $cordovaSQLite.execute is not a function
    at ChildScope.$scope.insertNewItem (addnewitemCtrl.js:12)
    at fn (eval at compile (ionic.bundle.js:27643), <anonymous>:4:230)
    at ionic.bundle.js:65429
    at ChildScope.$eval (ionic.bundle.js:30400)
    at ChildScope.$apply (ionic.bundle.js:30500)
    at HTMLInputElement.<anonymous> (ionic.bundle.js:65428)
    at defaultHandlerWrapper (ionic.bundle.js:16792)
    at HTMLInputElement.eventHandler (ionic.bundle.js:16780)
    at triggerMouseEvent (ionic.bundle.js:2953)
    at tapClick (ionic.bundle.js:2942)
在我的app.js中,我创建了数据库和表;以下是我的应用程序js代码片段:

if (window.cordova) {
      db = $cordovaSQLite.openDB({ name: "pos.db" }); //device
     console.log("not in browser");
    }else{
      db = window.openDatabase("pos.db", '1', 'my', 1024 * 1024 * 100); // browser
      console.log("browser");

    }

    $cordovaSQLite.execute(db,"CREATE TABLE IF NOT EXISTS items(id integer primary key,itemname text)");
  <form id="addNewItem-form2" class="list" ng-submit="submitForm(item)">
      <label class="item item-input item-floating-label" id="addNewItem-input4">
        <span class="input-label" ">Item name</span>
        <input type="text" ng-model="item.itemname" placeholder="enter item name">

       <input type="submit" ng-click="insertNewItem()" class="button button-block button-positive" value="Submit">
    </form>
我只想将项目名称添加到数据库中。以下是我的表单模板代码片段:

if (window.cordova) {
      db = $cordovaSQLite.openDB({ name: "pos.db" }); //device
     console.log("not in browser");
    }else{
      db = window.openDatabase("pos.db", '1', 'my', 1024 * 1024 * 100); // browser
      console.log("browser");

    }

    $cordovaSQLite.execute(db,"CREATE TABLE IF NOT EXISTS items(id integer primary key,itemname text)");
  <form id="addNewItem-form2" class="list" ng-submit="submitForm(item)">
      <label class="item item-input item-floating-label" id="addNewItem-input4">
        <span class="input-label" ">Item name</span>
        <input type="text" ng-model="item.itemname" placeholder="enter item name">

       <input type="submit" ng-click="insertNewItem()" class="button button-block button-positive" value="Submit">
    </form>


依赖项注入注释和函数参数的顺序不匹配

在您的代码中,
$cordovaSQLite
实际上是
itemFormData
,它没有执行方法

确保所有项目以相同的顺序出现:

.controller('addNewItemCtrl', ['$scope', '$stateParams','$state','$cordovaSQLite','itemFormData','$ionicPlatform', 
  function ($scope, $stateParams,$state,$cordovaSQLite,itemFormData, $ionicPlatform) {
    // $cordovaSQLite is now the expected object 
}])

非常感谢你的工作。但是,即使我将列名设置为'itemname',它仍然显示错误:SQLError{code:5,消息:“无法准备语句(1个表项没有名为itemname的列)”}。您还没有在
创建表
中创建名为
itemname
的列。