I'm doing an angularjs app using google maps api v3 and a plugin called ng-map. But I want to store some coordinates in a SQLite database and then retrieve from the app.
4 Answers
Basically, you can not. But you can use a SQLite cordova plugin if you are developing a hybrid mobile application.
http://ngcordova.com/docs/plugins/sqlite/ is one of the best SQLite plugins for cordovajs.
If you are looking for a cross-browser data storage mechanism, you can use IndexedDB.
http://www.w3.org/TR/IndexedDB/
https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
5 Comments
mallorca
Can I use IndexedDB offline ?
Jonathan Smith
Its not whether IndexedDB can be used offline, its whether the app works offline. If you use a HTML5 appcache manifest, you can use it offline. That's how our offline HTML5 app works. Are you looking at doing an in-browser app, or a hybrid app using something like Ionic?
mallorca
I'm trying to do an in-browser app.
Jonathan Smith
In that case, you will want to look at the HTML5 appcache manifest to make sure your pages are available offline, then you can also use IndexedDB offline. This will work on Safari, Chrome and Internet Explorer
Sumit
@JonathanSmith could you please provide some more information on how to develop an offline HTML5 app?
I was looking for the same thing few days before, after googling a lot I found this angular-sqlite package which kind of helped me, we have 2 options
- angular-sqlite package
- ngCordova
Try of this helps you
.constant('DB_CONFIG', {
client: {
id: key,
name: { type: 'text', null: false },
email: { type: 'text' },
id_zone: { type: 'integer' }
},
zone: {
id: 'key',
name: { type: 'text', null: false }
}
})
.run(function ($SQLite) {
$SQLite.dbConfig({
name: 'my-browser-db',
description: 'Test DB',
version: '1.0'
});
})
.run(function ($SQLite, DB_CONFIG) {
$SQLite.init(function (init) {
angular.forEach(DB_CONFIG, function (config, name) {
init.step();
$SQLite.createTable(name, config).then(init.done);
});
init.finish();
});
});