I am using Angular Websql (which is at https://github.com/paulocaldeira17/angular-websql) to create WEBSQL database.
This is my code in controller:
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 }); }; })
You can see it at my pInkr.co
When I run on my computer, it has errors: $scope.db is undefined and openDatabase is not defined.
When I add a new function showAll(), it gets error.
I can't find any error in my code.
Please help me to solve this.