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?

1
  • you can't able to write to external files Commented Jan 9, 2017 at 12:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

That's how it is done in JS, it is the same way is it?
TypeScript will be compiled to JS, therefore in the end it's the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.