1
我有一個問題來填充sqlite回調函數中的變量。那麼我怎樣才能讓這個var填充?因爲我想從查詢中返回值。AngularJs + Sqlite - 在sqlite回調函數中填充變量
這是我的代碼。
情況1:
module.controller('MasterController7', function($scope, $data) {
var hihi = [];
$scope.queryResult = function() {
\t \t database = window.openDatabase("Apps", "1.0", "Apps Database", 200000);
\t \t database.transaction(function(tx){
\t \t var sql = "";
\t \t \t \t \t
\t \t tx.executeSql(sql, [],
\t \t function(tx, response)
\t \t { \t
//hihi is not populated, the query ran successfuly.
\t \t \t hihi.push({title:'title',label:'label',desc:'desc'});
\t \t },
\t \t function(err)
\t \t {
\t \t \t //alert('aaaaaaa');
\t \t }
);
}, errorDB, successDB);
\t \t \t \t
};
\t \t \t
\t $scope.queryResult();
\t $scope.items = hihi;
});
<ons-list ng-controller="MasterController7">
<ons-list-item modifier="chevron" class="item" ng-repeat="item in items" ng-click="menu.setMainPage('favoritesurah.html', {closeMenu: true}); showDetail($index, item.title)">
<ons-row>
<ons-col width="60px">
<div class="item-thum"></div>
</ons-col>
<ons-col>
<header>
<span class="item-title">{{item.title}}</span>
<span class="item-label">{{item.label}}</span>
</header>
<p class="item-desc">{{item.desc}}</p>
</ons-col>
</ons-row>
</ons-list-item>
</ons-list>
P/S:使用溫泉UI即時通訊。