Problem with sqlite delete by id, item undefined


#1

Hello,

I want to delete a row from sqlite my code is as below:

app.js
`
try {
db = $cordovaSQLite.openDB({name:“inbox.db”,location:‘default’});
} catch (error) {
alert(error);
}

        $cordovaSQLite.execute(db, 'CREATE TABLE IF NOT EXISTS Messages (id INTEGER PRIMARY KEY AUTOINCREMENT, message TEXT)');

`

controllers.js

` $scope.remove = function(item) {
var query = “DELETE FROM Messages WHERE id = ?”;

        $cordovaSQLite.execute(db, query, [item.id]).then(function(res) {
            console.warn('after query >  ' + item.id);
        }, function (err) {
            console.warn('error on deleting freaking off');
            console.error(err);
        });
    };`

and in html file I used ng-click="remove(item)"
and I get “undefined” for item.id
apparently I need to define item first but can’t figure out what to do!

Thank you

following is not working for me