简体   繁体   中英

Update JSON key value - AngularJS

If I have a JSON file that contains a key, "text", and has an empty value how can I update the empty value?

I am using angularjs to make it interact with the user. I am also using $http.get to retrieve the json file. I am able to save the text to localstorage but I am having trouble sending the localstorage value into the JSON file. Overall I want the user to refresh the page and the text to still be there.

This is just a general overview of what I want to do which is why I am not providing code. All I want to do is figure out how, if possible, to update the JSON file so that next time it is refreshed and the $http.get is called again, the key has an updated value and it is displayed.

The basic step is to write a server side script (in perl/python/php etc) and then do an http post request from your AngularJS and your script updates the file in question. This is a good link to understand how to do it in python http://www.pythonschool.net/server-side-scripting/introduction-to-server-side-scripting/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM