angular-file-saver

WebJar for angular-file-saver

Лицензия

Лицензия

MIT
Категории

Категории

Angular Взаимодействие с пользователем Веб-фреймворки
Группа

Группа

org.webjars.bower
Идентификатор

Идентификатор

angular-file-saver
Последняя версия

Последняя версия

1.1.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

angular-file-saver
WebJar for angular-file-saver
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/alferov/angular-file-saver

Скачать angular-file-saver

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.bower/angular-file-saver/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>angular-file-saver</artifactId>
    <version>1.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/angular-file-saver/
implementation 'org.webjars.bower:angular-file-saver:1.1.3'
// https://jarcasting.com/artifacts/org.webjars.bower/angular-file-saver/
implementation ("org.webjars.bower:angular-file-saver:1.1.3")
'org.webjars.bower:angular-file-saver:jar:1.1.3'
<dependency org="org.webjars.bower" name="angular-file-saver" rev="1.1.3">
  <artifact name="angular-file-saver" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='angular-file-saver', version='1.1.3')
)
libraryDependencies += "org.webjars.bower" % "angular-file-saver" % "1.1.3"
[org.webjars.bower/angular-file-saver "1.1.3"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.bower : blob-polyfill jar [1.0.20150320,1.1)
org.webjars.bower : file-saver.js jar [1.20150507.2,1.20150508)

Модули Проекта

Данный проект не имеет модулей.

Angular File Saver

NPM version Build Status Dependency Status

Angular File Saver is an AngularJS service that leverages FileSaver.js and Blob.js to implement the HTML5 W3C saveAs() interface in browsers that do not natively support it

Dependencies

File dist/angular-file-saver.bundle.js contains all required dependencies and grants access to both Blob.js and FileSaver.js polyfills via Blob and SaveAs services.

Installation

# Using bower:
$ bower install angular-file-saver

# Using npm:
$ npm install angular-file-saver

Basic usage

  • Include ngFileSaver module into your project;
  • Pass both FileSaver and Blob services as dependencies;
  • Create a Blob object by passing an array with data as the first argument and an object with set of options as the second one: new Blob(['text'], { type: 'text/plain;charset=utf-8' });
  • Invoke FileSaver.saveAs with the following arguments:
    • data Blob: a Blob instance;
    • filename String: a custom filename (an extension is optional);
    • disableAutoBOM Boolean: (optional) Disable automatically provided Unicode text encoding hints;

Demo

API

FileSaver

A core Angular factory.

#saveAs(data, filename[, disableAutoBOM])

Immediately starts saving a file

Parameters

  • Blob data: a Blob instance;
  • String filename: a custom filename (an extension is optional);
  • Boolean disableAutoBOM : (optional) Disable automatically provided Unicode text encoding hints;

Blob(blobParts[, options]))

An Angular factory that returns a Blob instance.

SaveAs(data, filename[, disableAutoBOM])

An Angular factory that returns a FileSaver.js polyfill.

Example

JS

function ExampleCtrl(FileSaver, Blob) {
  var vm = this;

  vm.val = {
    text: 'Hey ho lets go!'
  };

  vm.download = function(text) {
    var data = new Blob([text], { type: 'text/plain;charset=utf-8' });
    FileSaver.saveAs(data, 'text.txt');
  };
}

angular
  .module('fileSaverExample', ['ngFileSaver'])
  .controller('ExampleCtrl', ['FileSaver', 'Blob', ExampleCtrl]);

HTML

<div class="wrapper" ng-controller="ExampleCtrl as vm">
  <textarea
    ng-model="vm.val.text"
    name="textarea" rows="5" cols="20">
      Hey ho let's go!
  </textarea>
  <a href="" class="btn btn-dark btn-small" ng-click="vm.download(vm.val.text)">
    Download
  </a>
</div>

License

MIT © Philipp Alferov

Версии библиотеки

Версия
1.1.3
1.1.2
1.1.0
1.0.2
0.7.1
0.0.4