admin管理员组

文章数量:1327661

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

本文标签: javascriptHow to create and update JSON file in angularjsStack Overflow