Reputation: 880
How to write to an external file using typescript in angular2 (client side) ? I need to write some text into a file in some format. Can anyone help? I googled and saw only how to do using node library or javascript blob. Is there a typescript way of doing it?
Upvotes: 1
Views: 13787
Reputation: 657118
You can't write to local files. The code runs in the browser and the browser will prevent access to the local file system. What you can do is to create a download link with a data url, that the user clicks and saves to a file.
See also How to read and write into file using JavaScript for a limited way to writ to local files.
Upvotes: 1