I have a pre-filled SQLITE database and I want to do is can use these data to create a "service" or a "factory" in an application with IONIC project.
I did successfully the integration of the database with the project after following this tutorial https://blog.nraboy.com/2015/01/deploy-ionic-framework-app-pre-filled-sqlite-db/ , so too, without problems I can get data from the database in the application.
Now I want to populate a "service" or "factory" with these database's data to later populate others views in the project.
Is that possible?? Do you have another possible solution to dinamically populate the application with the pre-filled database?
if youre building a mobile app using ionic and cordova that means youre using the cordova storage apis wich takes the javascript websql for that, if thats your case you could just use this library in your project and everithing should work nice and integrated with angular
it has predifiden methods to work with your database so youll just need to do something like this in your app
in the angular run inject the '$webSql' and '$rootScope' and do:
$rootScope.DB = $webSql.openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
and then you can do this in your controllers:
$scope.DB.select("user", {"age": {"value":'IS NULL'}, "username":'IS NOT NULL'
}).then(function(results) {
$scope.users = [];
for(i=0; i < results.rows.length; i++){
$scope.users.push(results.rows.item(i));
}
})
see the documentation for more info, also theres an executeQuery method not listed but is usefull for raw queries