Although I don’t recommend using the Web sql database, here is your working app:
I imagine that you had a typo, or you didn’t call $scope.$apply()
http://play.ionic.io/app/b3609dae4d01
Here’s the code, incase the play changes:
.controller('testController', function($scope) {
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
$scope.categories = [];
db.transaction(function(tx) {
tx.executeSql('DROP TABLE branch_locations');
tx.executeSql('CREATE TABLE IF NOT EXISTS branch_locations (slno, branch_name, branch_code)');
tx.executeSql('INSERT INTO branch_locations (slno, branch_name, branch_code) VALUES (?, ?, ?)', [1, 'test_name', 'test_code']);
tx.executeSql('INSERT INTO branch_locations (slno, branch_name, branch_code) VALUES (?, ?, ?)', [2, 'test_name', 'test_code']);
tx.executeSql('SELECT * FROM branch_locations', [], function (tx, results) {
var len = results.rows.length;
for (var i = 0; i < len; i++) {
$scope.categories.push({
slno: results.rows.item(i).slno,
branch_name: results.rows.item(i).branch_name,
branch_code: results.rows.item(i).branch_code
});
// Make sure to apply scope change so that ng-repeat updates
$scope.$apply();
}
});
}, function(error) {
console.log(error)
});
});
<body ng-app="app" ng-controller="testController">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Awesome App</h1>
</ion-header-bar>
<ion-content class="padding">
<ion-list>
<ion-item ng-repeat="category in categories">
<h2>{{category.slno}} {{category.branch_code}}</h2>
<h2>Branch: {{category.branch_name}}</h2>
</ion-item>
</ion-list>
</ion-content>
</ion-pane>
</body>