Reputation: 1636
Node Code
var v = text1
v = v + "\n"
v = v + text2
res.status(200).send(v);
return
I tried this but in my text file string are not seperated by new line I have written this directive after getting the result in angular client
Angular Code
$(anchor).attr({
//href: 'data:text/json;charset=utf-8,' + JSON.stringify(data),
href: 'data:text/json;charset=utf-8,' + (data.data),
download: attr.filename
})
Upvotes: 0
Views: 115
Reputation: 1636
I got my answer, The problem was with encoding data.
href: 'data:text/plain;charset=utf-8,' + encodeURIComponent(data)
Now I got the text file seperated by new line.
Upvotes: 1
Reputation: 68635
Use a new ES6 interpolation syntax:
var v = 'Hello';
var text2 = 'World!'
v = `${v}
${text2}`;
console.log(v)
Upvotes: 1