Websql with select sql

Hi Team,

I am suffering with a issue in websql, this is example of code “controller.js”

$scope.totalamts = function() {
			var tamounts;
			 db.transaction(function (tx) {
				tx.executeSql("SELECT SUM(totalamt) as tas FROM TempCart", [], function(tx, results) {
					if(results.rows.length > 0) {
						for(var i = 0; i < results.rows.length; i++) {
							/* tamount[] = results.rows.item(i).tas */
							/* console.log("R![image](upload://ke6PK59wvfGOFn62ggjBfEOepcd.png) " + results.rows.item(i).tas ); */
						}
						tamounts = results.rows.item(0).tas
						console.log(tamounts);
					}
				});
			});
			return tamounts;
		}

I want to return amount in this function but console.log print value but function did not return the value can you please help me to solve this bug, I am just calling this function from menu page html code is “menu.html”

<div class="row">
					<div class="col ">
							<i class="fa fa-inr fa-lg p c txt_white" >{{totalamts()}}</span></i>
						</div>
						
						<div class="col">
							<i class="fa fa-shopping-cart fa-lg p c txt_white pull-right"><span>{{totalqtys()}}</span></i>
					</div>
				</div>

hi,
Your console log is in the right place, the return didn’t.

Add a callback function to your method which receive 2 arguments (err, data) and call it just after the console statement passing null as err and tamounts as data