I'm trying to fetch a list of clients from my database and display it as a listview, but when I run the app I get the following error:
Error: Failed to read the 'insertId' property from 'SQLResultSet': The query didn't result in any rows being added.
Can't see what I'm missing here, any help will be appreciated!
dbFactory.method = function findAll() {
db.transaction(
function(tx) {
var sql = "SELECT (nome) as nomes FROM clientes";
tx.executeSql(sql, [],
function(tx, results) {
var len = results.rows.length,
clientes = [],
i = 0;
for (; i < len; i = i + 1) {
clientes[i] = results.rows.item(i).nomes;
deferred.resolve(results);
}
log(clientes + ' rows found');
}
);
},txErrorHandler,
function () {
}
);
return deferred.promise;
};
Controller:
.controller('ListaCtrl', function ($scope, dbFactory) {
$scope.clientes = dbFactory.method();
//console.log(dbFactory.method());
dbFactory.method().then(function(response){
console.log(JSON.stringify(response));
});
});
html:
<ion-view view-title="Playlists" ng-app="starter">
<ion-content>
<ion-list ng-controller = "ListaCtrl">
<ion-item ng-repeat="itens in clientes" >
<p>{{itens.nome}}</p>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
Aucun commentaire:
Enregistrer un commentaire