3

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!

2
  • Here's the latest & greatest blog.backlift.com/entry/angular-tut1 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? Commented Jun 11, 2013 at 3:54

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.