I am new to angular 6 and Node as well. Basically I have a requirement of creating a text file on button click and saving it to server using Node. Te save file will be in .txt format so that I could read from it again. I was trying using ng2-file-upload, but that is helpful for upload and save. Not getting any clue how to proceed! I got the reference of File System API. How to use it from my Angular 6 Code? Thanks in advance for help!!
Asked
Active
Viewed 724 times
0
-
You are missing the part where you explain where the text in the text file is coming from. I assume it's some sort of text box on the page? – Bronzdragon Dec 20 '18 at 18:47
-
Possible duplicate of [Writing files in Node.js](https://stackoverflow.com/questions/2496710/writing-files-in-node-js) – Bronzdragon Dec 20 '18 at 18:47
-
Yes, you are correct. As per my requirement, I need to create a .txt file on a form submission with the form input contents. – nitu Dec 31 '18 at 11:32
-
I tried to use the below code `const fs = require('fs'); fs.writeFile("/tmp/test", "Hey there!", function(err) { if(err) { return console.log(err); } console.log("The file was saved!"); }); ` I am getting error "Module not found" As per https://stackoverflow.com/questions/50202948/update-to-angular-v6-module-not-found-error-cant-resolve-fs, the node modules can't be accessed from Angular6. any alternatives? – nitu Jan 02 '19 at 10:26
-
It looks like you'll have to use an external library to get it done: http://alferov.github.io/angular-file-saver/ for example. – Bronzdragon Jan 02 '19 at 10:43