I am trying to create a registration form. Once the form is submitted, I just want to save the data to local storage.
Could anyone give me an example or point me to a tutorial that could help me out?
You can use lokiJS or SQLite or even Basic Internal Get/Set.
Take a look at my question and answers:
SQLite: Save ,retrieve and upload data to a remote server---(AngularJs / Ionic)
Basic Internal Get/Set Service: Angular Service To Set And Retrieve Object Between Controllers
LokiJS(NOSQL): http://lokijs.org/#/
http://gonehybrid.com/how-to-use-lokijs-for-local-storage-in-your-ionic-app/
LocalStorage/Session Storage :
You can also make use of existing HTML 5 local/session storage.
For just a form, you may just want to use basic internal getter/setter, that should suffice for most cases. I haven tried lokiJS personally, but i think it's good!
I prefer using the GitHub Library Angular Local Storage in my AngularJS and Cordova/Ionic projects.
https://github.com/grevory/angular-local-storage
Set Key in Local Storage
myApp.controller('MainCtrl', function($scope, localStorageService) {
//...
function submit(key, val) {
return localStorageService.set(key, val);
}
//...
});
Get Key in Local Storage
myApp.controller('MainCtrl', function($scope, localStorageService) {
//...
function getItem(key) {
return localStorageService.get(key);
}
//...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With