我正在使用Angular Websql(位于https://github.com/paulocaldeira17/angular-websql)来创建WEBSQL数据库。
这是我在控制器中的代码:
angular.module('myCtrl', ['angular-websql']) .controller('AdminCtrl', function($scope, $webSql){ $scope.db = $webSql.openDatabase('MyDB', '1.0', 'My Database', 5*1024*1024); $scope.db.createTable('TemplateTbl', { "id": { "type": "INTEGER", "null": "NOT NULL", "primary": true, "auto_increment": true }, "tempTitle": { "type": "TEXT", "null": "NOT NULL" }, "tempContent": { "type": "TEXT", "null": "NOT NULL" }, "tempInstruction": { "type": "TEXT", "null": "NULL" }, "tempSentences": { "type": "TEXT", "null": "NULL" }, "categoryID": { "type": "INTEGER", "null": "NOT NULL" }, "dateCreated": { "type": "TIMESTAMP", "null": "NOT NULL", "default": "CURRENT_TIMESTAMP" } }); $scope.addTemplate = function(){ $scope.db.insert('TemplateTbl',{ "tempTitle": $scope.template.title, "tempContent": $scope.template.content, "tempInstruction": $scope.template.instruction, "tempSentences": $scope.template.sentences, "categoryID": $scope.template.category }); }; })
你可以在我的pInkr.co上看到它
当我在计算机上运行时,它有错误:$ scope.db未定义且未定义openDatabase。
当我添加新函数showAll()时,它会出错。
我在代码中找不到任何错误。
请帮我解决这个问题。