How do I update/add to a JSON file using angularJS?

前端 未结 1 966
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 03:26

I\'ve created a local JSON file and am able to get data from the file using

app.controller(\'appCtrl\', function($scope, $http){
  $http.get(\'employees.json\')         


        
相关标签:
1条回答
  • 2021-01-23 04:07

    I don't think it's possible to do that directly from Angular. There are some other sources that you integrate into your app, which you can then have Angular leverage.

    • Exploring the FileSystem API (HTML5) - verify which browsers support this.
    • Another options is jQuery.twFile.

    You could also just store it as localstorage and access it as you would just about any other object. This would be the method that I'd lean towards more (depending on the size). Otherwise I've always had to have the server-side do it.

    0 讨论(0)
提交回复
热议问题