AngularJs+;Sqlite-在Sqlite回调函数中填充变量
我在sqlite回调函数中填充变量时遇到问题。那么我怎样才能让这个变量被填充呢?因为我想从查询中返回值 这是我的密码 情景1:AngularJs+;Sqlite-在Sqlite回调函数中填充变量,angularjs,sqlite,cordova,onsen-ui,Angularjs,Sqlite,Cordova,Onsen Ui,我在sqlite回调函数中填充变量时遇到问题。那么我怎样才能让这个变量被填充呢?因为我想从查询中返回值 这是我的密码 情景1: module.controller('MasterController7',函数($scope,$data){ var hihi=[]; $scope.queryResult=函数(){ 数据库=window.openDatabase(“应用程序”,“1.0”,“应用程序数据库”,200000); 数据库事务(功能(tx){ var-sql=“”; tx.execute
module.controller('MasterController7',函数($scope,$data){
var hihi=[];
$scope.queryResult=函数(){
数据库=window.openDatabase(“应用程序”,“1.0”,“应用程序数据库”,200000);
数据库事务(功能(tx){
var-sql=“”;
tx.executeSql(sql,[],
功能(发送、响应)
{
//hihi未填充,查询已成功运行。
push({title:'title',label:'label',desc:'desc'});
},
功能(err)
{
//警报(‘AAAAA’);
}
);
},errorDB,successDB);
};
$scope.queryResult();
$scope.items=hihi;
});代码>
{{item.title}
{{item.label}
{{item.desc}
要获得查询结果,应将响应对象替换为$scope对象
您应该执行$scope.$apply方法,因为事务回调超出了范围
安格拉斯
例如,executeSql回调是
tx.executeSql(sql, [],
function(tx, response)
{
for (var i=0; i<response.rows.length; i++ ) {
var row = response.rows.item(i);
hihi.push({title:row.id,label:row.label,desc:row.name});
$scope.items = hihi;
$scope.$apply();
}
},
function(err)
{
//alert('aaaaaaa');
}
);
tx.executeSql(sql,[],
功能(发送、响应)
{
对于(var i=0;i