am trying to use factory to get an sqlite select result to use it in my controller
myDataFactory.FillDishesByCategory = function (CategoryNo) {
$ionicPlatform.ready(function () {
var query = "SELECT id , dishname , dishdiscription , dishprice , dishcategory , category , thumb_base64 , qty , backcolor FROM dishesmenu WHERE dishcategory = ?";
$cordovaSQLite.execute(db, query, [CategoryNo]).then(function (result) {
return result;
});
})
}
and in controller am using
var res = myDataFactory.FillDishesByCategory(CategoryNo);
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
$scope.selecteddishesmenu.push({
id: res.rows.item(i).id,
dishname: res.rows.item(i).dishname,
dishdiscription: res.rows.item(i).dishdiscription,
dishprice: res.rows.item(i).dishprice,
dishcategory: res.rows.item(i).dishcategory,
category: res.rows.item(i).category,
thumb_base64: res.rows.item(i).thumb_base64,
qty: res.rows.item(i).qty,
backcolor: res.rows.item(i).backcolor
});
}
};
am “getting rows undefiened”
any help on this ?