1

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?

keerthee
  • 812
  • 4
  • 17
  • 39

1 Answers1

1

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.

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567