typescript - Saving an array of objects in localStorage -


i'm trying add item localstorage array make array of objects , iterate somewhere in angular 2 app. how i'm trying save localstorage item:

if (!this.search_history) {     localstorage.setitem('search_history', json.stringify(this.calc)); } else {     localstorage.setitem('search_history', this.search_history + ',' + json.stringify(this.calc)); } 

and in component i'm trying iterate:

private searchhistory = json.parse(localstorage.getitem('search_history')) || []; 

i go confused how supposed work, think have problem way trying insert new array item. not sure if can use push in case.

what's proper syntax insert new array record?


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -