Ionic / AngularJS: How to save data locally from a form?

I am trying to create a registration form. After submitting the form, I just want to save the data in local storage.

Can someone give me an example or point me to a tutorial that could help me?

+4
source share
4 answers

You can use lokiJS or SQLite or even Basic Internal Get / Set.

Take a look at my question and answers:

SQLite: Save, load and upload data to a remote server --- (AngularJs / Ionic)

Get / Set: Angular Core Internal Service A service for setting and retrieving an 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:

/ HTML 5.

/, . lokiJS, , !

+4

GitHub Angular AngularJS Cordova/Ionic.

https://github.com/grevory/angular-local-storage

myApp.controller('MainCtrl', function($scope, localStorageService) {
  //...
  function submit(key, val) {
   return localStorageService.set(key, val);
  }
  //...
});

myApp.controller('MainCtrl', function($scope, localStorageService) {
  //...
  function getItem(key) {
   return localStorageService.get(key);
  }
  //...
});
+2

$window.localStorage. $window .

$windows.localStorage["key"]=jsonValue;
+1
source

check this link http://ionicframework.com/docs/guide/building.html and after submitting the form inside the function, use local storage, for example .. https://blog.nraboy.com/2014/12/use-ngstorage-angularjs -local-storage-needs / we need to enter ng-storage into the module, enter the local storage in the controller / service where you want to use it, and then store the presented data in local storage.

0
source

Source: https://habr.com/ru/post/1616304/


All Articles