我使用了cordova,sqlite和angular。我在ng-init中将此初始化函数称为html视图。此初始化函数不返回成功数据。但是这段代码是正确的。我的问题是如何在ng-init函数中调用sqlite获取数据
$scope.InsertMydevices = function() {
var userdata = CF2018.ETL.getUser();
userdata = userdata.UserName;
db.transaction(function(tx) {
tx.executeSql('SELECT * FROM DeviceModel WHERE CreateBy=?', [userdata], function (tx, res) {
var len = res.rows.length, i;
$scope.datalength = len;
alert($scope.datalength);
$scope.$apply();
}, null);
}, function(error) {
alert(error.message);
}, function() {
alert('datachecked');
});
}