JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myApp">
<div ng-controller="MyCtrl">
JSON: <input type="text" ng-model="json" />
<br/>
<a class="btn" download="backup.json" href="{{downloadLink}}">Download</a>
</div>
</div>
JavaScript
var module = angular.module('myApp', [])
.controller('MyCtrl', function ($scope){
var data = {a:1, b:2, c:3};
$scope.json = JSON.stringify(data);
$scope.downloadLink = window.URL.createObjectURL(new Blob([$scope.json], {type: "application/json"}));
}).config([ '$compileProvider',
function($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^s*(https?|ftp|blob|mailto|chrome-extension):/);
// pre-Angularv1.2 use urlSanizationWhitelist()
}
]);