简体   繁体   中英

Update local JSON file using AngularJS

The file performs.json contains an JSON array with objects of user info.

I want to programmatically update this array and save again. But I don't know how.

$http.get('db/performs.json')
    .then(function (res) {
        res.data.push(newSubmit);
        // Save this new res.data to db/performs.json
    });

When you call $http.get the server sends the file to you, it is then placed in memory, which you then modify. At this point you need to send the modified file back to the server for storage.

This needs to be supported by the server that served the file initially.

Here's an example of how to do in a NodeJS server

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