javascript - Persisting array data locally in AngularJS app to be shared between two applications -
i have array info var queries = [];
want persisted , shared between 2 angularjs application. 2 applications meaning 1 front end end , sec admin end. both ends create whole page load when loaded.
i tried using next code sharing info doesn't seem work:
.factory('queryservice', function() { var queries = []; var mill = {}; //.. factory.addquery = function(query) { queries.push(query); localstorage.setitem('queries', json.stringify(queries)); console.log(json.parse(localstorage.getitem('queries'))); homecoming json.parse(localstorage.getitem('queries')); }; //.. homecoming factory; }
i lastly element added queries
array above code.
i tried next using angular-local-storage still same result.
.factory('queryservice', ['localstorageservice', function(localstorageservice) { var queries = []; var mill = {}; //.. factory.addquery = function(query) { queries.push(query); localstorageservice.set('queries', queries); console.log(localstorageservice.get(('queries'))); homecoming localstorageservice.get(('queries')); }; //.. homecoming factory; }
i need array queries
info available in front end end app , in admin end.
could help me it?
use mill setup private variables specific mill can set , fetch value of private variable.
you create method clear queries variable if necessary.
.factory('queryservice', function () { var queries = []; var mill = {}; homecoming { addquery : function (query) { queries.push(query); localstorage.setitem('queries', json.stringify(queries)); console.log(json.parse(localstorage.getitem('queries'))); homecoming json.parse(localstorage.getitem('queries')); }, fetchquery : function ( ) { homecoming localstorage.getitem('queries'); } }; });
javascript arrays angularjs local-storage angular-local-storage
All the contents you mentioned in post is too good and can be very useful. I will keep it in mind, thanks for sharing the information keep updating, looking forward for more posts.Thanks
ReplyDeletecs代写