Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJs+;Sqlite-在Sqlite回调函数中填充变量_Angularjs_Sqlite_Cordova_Onsen Ui - Fatal编程技术网

AngularJs+;Sqlite-在Sqlite回调函数中填充变量

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

我在sqlite回调函数中填充变量时遇到问题。那么我怎样才能让这个变量被填充呢?因为我想从查询中返回值

这是我的密码

情景1:
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