最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to create and update JSON file in angularjs? - Stack Overflow

programmeradmin7浏览0评论

I just want to create a simple app which creates, updates, and deletes items in JSON file using AngularJS. I have looked online, only found examples which takes JavaScript objects to edit, or delete JSON type data. But I want to use JSON as backend in AngularJS.

Is there any examples out which can post data to JSON file?

Thanks in advance!

I just want to create a simple app which creates, updates, and deletes items in JSON file using AngularJS. I have looked online, only found examples which takes JavaScript objects to edit, or delete JSON type data. But I want to use JSON as backend in AngularJS.

Is there any examples out which can post data to JSON file?

Thanks in advance!

Share Improve this question asked Jun 11, 2013 at 3:39 MayurMayur 651 gold badge2 silver badges9 bronze badges 2
  • Here's the latest & greatest blog.backlift./entry/angular-tut1 – Terry Commented Jun 11, 2013 at 3:44
  • Thanks Terry, but I'm not able to download example there and also is there anything which can edit/add .json file? – Mayur Commented Jun 11, 2013 at 3:54
Add a ment  | 

1 Answer 1

Reset to default 5

Try something like:

angular.module('myApp').factory('MyJsonService', function() {
  return $resource('/:myFile.json', {myFile: '@file'});
});

Then in your controller:

$scope.myJsonContents = MyJsonService.get({file: 'myFilename'}); // keep in mind that this is async though
发布评论

评论列表(0)

  1. 暂无评论