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
1 Answer
Reset to default 5Try 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
版权声明:本文标题:javascript - How to create and update JSON file in angularjs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742229423a2436943.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论