mercredi 6 janvier 2016

Unable to Create database using angular js

I want to create a database. I tried alot but didnt succeed. Below is my code . Help me .Thanks in advance :)

<html ng-app="myControllers">

<head>
  <script data-require="angular.js@1.2.12" data-semver="1.2.12" src="http://ift.tt/1eiplZs"></script>
  <script>
    var myControllers = angular.module('myControllers', []);


    myControllers.controller('AuthCtrl', function($scope) {
      $scope.login = function() {
        var db = null;

        db = window.cordova.openDatabase("mrr.db");
        $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)");
        window.alert("Database Created");
      };
    });
  </script>
</head>

<body>
<form ng-controller="AuthCtrl">
  <input type="text" name="username" id="username" placeholder="Username" ng-model="username" />
  <input type="password" name="password" id="password" placeholder="Password"  ng-model="userpassword" />
  <button type="submit" ng-click="login();">Login</button>
</form>
</body>


</html>

Why the database is not being created. I referred many websites and I found same syntax for creating database but all in vain.

Aucun commentaire:

Enregistrer un commentaire