I\'m trying to write data to a json file after hitting \"Submit\" on an html formly-form using only angular, but nothing is happening. I know I can read a json file using an
The following code adds a download button for a JSON object.
Note: wrapping a button with an anchor tag is not recommended for HTML 5 yet it works in Chrome which is all I needed. YMMV.
HTML:
Typescript:
get dataUri(): SafeUrl {
const jsonData = JSON.stringify(this.dataSource);
const uri = 'data:application/json;charset=UTF-8,' + encodeURIComponent(jsonData);
return this.sanitizer.bypassSecurityTrustUrl(uri);
}