javascript - Update value in localstroage -
i have below value stored in angularjs localstroage. how update empno different value if empno exist.
{"employerdetails":{"distance":30,"emplatitude":51.3353899,"emplongitude":-0.742856,"empno":4,"insitution":null,"placename":"camberley","talentpoollicences":[{"membership":[{"identity":4,"name":"test school account"}],"talentpooltype":1},{"membership":[{"identity":2,"name":"north east hampshire"},{"identity":4,"name":"surrey"},{"identity":8,"name":"surrey"}],"talentpooltype":3}]},"facetfilters":{"lastactivity":0,"locationfiltertype":1,"fullorparttime_pex":null,"membership_tpl":["e4","r2","r4","r8"],"religion":null,"soughtphase_swk":null,"soughtrole_swk":null,"soughtsubject_swk":null},"lookingfor":null,"orderby":null,"pageindex":1,"pagesize":40}
i have tried below doesnt sems working:
localstorage.setitem(localstorage.key(0).employerdetails[empno],999);
you need retrieve local stored value , update follows,
var storedobj = json.parse(localstorage.getitem('yourname'); //update storedobj.employerdetails.empno = '5'; //store again localstorage.setitem('yourname', json.stringify(storedobj));
Comments
Post a Comment