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?
Asked
Active
Viewed 1.4k times
1
-
you can't able to write to external files – balajivaishnav Jan 09 '17 at 12:21
1 Answers
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
-
-
TypeScript will be compiled to JS, therefore in the end it's the same. – Günter Zöchbauer Jan 09 '17 at 12:22