Update a single property of local JSON file using put call in Angular 8

前端 未结 3 695
野性不改
野性不改 2021-01-27 16:11

I want to update my JSON file which I have placed in my assets folder, so If I am updating just one property of my JSON object so it should update that property only, without af

相关标签:
3条回答
  • 2021-01-27 16:50

    No! You cannot change a file’s content using Angular. It is a file I/O operation that is handled by a backend framework/language (for example Node.JS) having file system API. You can create a RESTful API to modify the contents of the file and make an HTTP call from Angular.

    0 讨论(0)
  • 2021-01-27 16:52

    You can't do any file operation using just angular framework. You need server side implementation to achieve this. If you are not familiar with server side programming you can try using in memory angular database api.

    https://www.npmjs.com/package/angular-in-memory-web-api

    0 讨论(0)
  • 2021-01-27 16:52

    You can't change the content of JSON file directly through angular, you need the Backend in order to reflect the change on that JSON file.

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