How do I save ionic array data in a .txt or .json file


#1

I have an array in ionic and I want to if I click a button called ‘save’ that a .txt or .json file should be created where the data in the array should then be saved. How can I achieve this with ionic? I’m very new to Ionic so I’d like to know how I can achieve this.

The array is as followed:.

testnames = [{name : "sheldon", age : "10"}, {name : "Simon", age : "11"}]

#2

You will need to use a Cordova plugin to write the file. Refer to the Ionic Native library for more information on this.

There is also Ionic Storage that might serve your needs better.