I want to call the method from the controller of the angularjs from the javascript method. So I used following function to call.
function ValidateLogin(data) {
var currentUser = angular.element(document.getElementById('bdyIndex')).scope().SlateProject_GetCurrentUser();
if (currentUser.rows.length > 0) {
//doing the stuff
}
}
Controller looks like following
angular.module('indexApp', [])
.controller('indexController', function ($scope, $http) {
$scope.SlateProject_GetCurrentUser = function () {
var db = app.db;
db.transaction(function (tx) {
tx.executeSql("SELECT * FROM dbSlateProject WHERE ACTIVE = 1", [],
function (tx, e) {
console.log('Fetched Active Slate Project!')
return e;
},
function (tx, e) {
alert(e.message);
});
});
}
});
So before getting the result from "SlateProject_GetCurrentUser", the if condition is executed. So it gives error as "Cannot read property 'rows' of undefined". How can we call the method by sync.