I am creating a project in Phonegap with Ionic.I am inserting and fetching dynamic content with sqlite and local storage.
I created a Dashboard contoller below are my dashboard controller code
angular.module('myWallet').controller('dashCtrl',
function($scope,$state,$ionicPopup,$ionicHistory,AuthService){
$scope.data = {};
//goBack
$scope.myGoBack = function() {
$ionicHistory.goBack();
};
//********** error code function ************
function errorDashFunction(err)
{
alert("Error Code: "+error.code);
}
//********** Success code function ************
function successDashFunction()
{
var totalCashInHand = Coming_totalIncome - Coming_totalExpenses;
alert(totalCashInHand );
}
var current_user_id=window.localStorage.getItem('userid');
var Coming_totalIncome = 0;
var Coming_totalExpenses= 0;
var Coming_totalCashInHand = 0;
//********** Fetching Values from DB ************
db.transaction(function (tx) {
tx.executeSql("SELECT SUM(amount) as Totalincome FROM WALLET_INCOMES WHERE user_id ='"+current_user_id+"'", [], function(tx,results){
console.log(results);
if(results.rows[0].Totalincome != null)
{
Coming_totalIncome = results.rows[0].Totalincome;
}
});
tx.executeSql("SELECT SUM(amount) as Totalexpenses FROM WALLET_EXPENSES WHERE user_id ='"+current_user_id+"'", [], function(tx,results){
if(results.rows[0].Totalexpenses != null)
{
Coming_totalExpenses = results.rows[0].Totalexpenses;
}
});
return true;
},errorDashFunction,successDashFunction);
})
When i run this code on Ripple then it is alerting TotalCashInHand Price. BUT when i am running this code on my mobile then it is always showing Error code "0".
Aucun commentaire:
Enregistrer un commentaire