22
33[ ![ NPM version] [ npm-image ]] [ npm-url ]
44[ ![ Build Status] [ travis-image ]] [ travis-url ]
5- [ ![ Dependency Status] [ depstat-image ]] [ depstat-url ]
65
76> Angular File Saver is an AngularJS service that leverages
8- [ FileSaver.js] ( https://github.com/eligrey/FileSaver.js/ ) and
9- [ Blob.js] ( https://github.com/eligrey/Blob.js/ ) to implement the HTML5 W3C
10- saveAs() interface in browsers that do not natively support it
7+ > [ FileSaver.js] ( https://github.com/eligrey/FileSaver.js/ ) and
8+ > [ Blob.js] ( https://github.com/eligrey/Blob.js/ ) to implement the HTML5 W3C
9+ > saveAs() interface in browsers that do not natively support it
1110
1211## Dependencies
12+
1313- [ Angular] ( https://github.com/angular/angular.js )
1414- [ FileSaver.js] ( https://github.com/eligrey/FileSaver.js/ )
1515- [ Blob.js] ( https://github.com/eligrey/Blob.js/ )
@@ -29,11 +29,12 @@ $ npm install angular-file-saver
2929```
3030
3131## Basic usage
32+
3233- Include ` ngFileSaver ` module into your project;
3334- Pass both ` FileSaver ` and ` Blob ` services as dependencies;
3435- Create a [ Blob object] ( https://developer.mozilla.org/en/docs/Web/API/Blob ) by
35- passing an array with data as the first argument and an object with set of options
36- as the second one: ` new Blob(['text'], { type: 'text/plain;charset=utf-8' }) ` ;
36+ passing an array with data as the first argument and an object with set of options
37+ as the second one: ` new Blob(['text'], { type: 'text/plain;charset=utf-8' }) ` ;
3738- Invoke ` FileSaver.saveAs ` with the following arguments:
3839 - ` data ` ** Blob** : a Blob instance;
3940 - ` filename ` ** String** : a custom filename (an extension is optional);
@@ -42,33 +43,42 @@ as the second one: `new Blob(['text'], { type: 'text/plain;charset=utf-8' })`;
4243[ Demo] ( http://alferov.github.io/angular-file-saver/#demo )
4344
4445## API
46+
4547### ` FileSaver `
48+
4649A core Angular factory.
50+
4751#### ` #saveAs(data, filename[, disableAutoBOM]) `
52+
4853Immediately starts saving a file
4954
5055#### Parameters
56+
5157- ** Blob** ` data ` : a Blob instance;
5258- ** String** ` filename ` : a custom filename (an extension is optional);
5359- ** Boolean** ` disableAutoBOM ` : (optional) Disable automatically provided Unicode text encoding hints;
5460
5561### ` Blob(blobParts[, options])) `
62+
5663An Angular factory that returns a [ Blob instance] ( https://developer.mozilla.org/en/docs/Web/API/Blob ) .
5764
5865### ` SaveAs(data, filename[, disableAutoBOM]) `
66+
5967An Angular factory that returns a [ FileSaver.js polyfill] ( https://github.com/eligrey/FileSaver.js/#syntax ) .
6068
6169## Example
70+
6271** JS**
72+
6373``` js
6474function ExampleCtrl (FileSaver , Blob ) {
6575 var vm = this ;
6676
6777 vm .val = {
68- text: ' Hey ho lets go!'
78+ text: ' Hey ho lets go!' ,
6979 };
7080
71- vm .download = function (text ) {
81+ vm .download = function (text ) {
7282 var data = new Blob ([text], { type: ' text/plain;charset=utf-8' });
7383 FileSaver .saveAs (data, ' text.txt' );
7484 };
@@ -80,11 +90,10 @@ angular
8090```
8191
8292** HTML**
93+
8394``` html
8495<div class =" wrapper" ng-controller =" ExampleCtrl as vm" >
85- <textarea
86- ng-model =" vm.val.text"
87- name =" textarea" rows =" 5" cols =" 20" >
96+ <textarea ng-model =" vm.val.text" name =" textarea" rows =" 5" cols =" 20" >
8897 Hey ho let's go!
8998 </textarea >
9099 <a href =" " class =" btn btn-dark btn-small" ng-click =" vm.download(vm.val.text)" >
@@ -94,13 +103,10 @@ angular
94103```
95104
96105## License
106+
97107MIT © [ Philipp Alferov] ( https://github.com/alferov )
98108
99109[ npm-url ] : https://npmjs.org/package/angular-file-saver
100110[ npm-image ] : https://img.shields.io/npm/v/angular-file-saver.svg?style=flat-square
101-
102111[ travis-url ] : https://travis-ci.org/alferov/angular-file-saver
103112[ travis-image ] : https://img.shields.io/travis/alferov/angular-file-saver.svg?style=flat-square
104-
105- [ depstat-url ] : https://david-dm.org/alferov/angular-file-saver
106- [ depstat-image ] : https://david-dm.org/alferov/angular-file-saver.svg?style=flat-square
0 commit comments