ngx-filesaver
Advanced tools
Comparing version 15.0.0 to 15.0.1
{ | ||
"name": "ngx-filesaver", | ||
"version": "15.0.0", | ||
"version": "15.0.1", | ||
"description": "Simple file save with FileSaver.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -17,13 +17,19 @@ # ngx-filesaver | ||
```sh | ||
$ npm install file-saver ngx-filesaver | ||
# Or when using yarn | ||
$ yarn add file-saver ngx-filesaver | ||
# Or when using pnpm | ||
$ pnpm install file-saver ngx-filesaver | ||
``` | ||
npm install file-saver ngx-filesaver --save | ||
``` | ||
Add the `FileSaverModule` module to your project: | ||
``` | ||
```ts | ||
import { FileSaverModule } from 'ngx-filesaver'; | ||
@NgModule({ | ||
imports: [ FileSaverModule ] | ||
imports: [FileSaverModule], | ||
}) | ||
export class AppModule {} | ||
``` | ||
@@ -55,11 +61,15 @@ | ||
```html | ||
<button type="button" | ||
fileSaver | ||
[method]="'GET'" | ||
[fileName]="'中文pdf.pdf'" | ||
[url]="'assets/files/demo.pdf'" | ||
[header]="{ token: 'demo' }" | ||
[query]="{ pi: 1, name: 'demo' }" | ||
(success)="onSuc($event)" | ||
(error)="onErr($event)">Download PDF</button> | ||
<button | ||
type="button" | ||
fileSaver | ||
[method]="'GET'" | ||
[fileName]="'中文pdf.pdf'" | ||
[url]="'assets/files/demo.pdf'" | ||
[header]="{ token: 'demo' }" | ||
[query]="{ pi: 1, name: 'demo' }" | ||
(success)="onSuc($event)" | ||
(error)="onErr($event)" | ||
> | ||
Download PDF | ||
</button> | ||
``` | ||
@@ -70,12 +80,12 @@ | ||
Parameter | Description | Type | Default | ||
----|------|-----|------ | ||
`method` | Request method type | `string` | `GET` | ||
`url` | Request URL | `string` | - | ||
`fileName` | Filename when downloading | `string` | - | ||
`query` | Additional query parameters. Equivalent to `params` value | `string` | - | ||
`header` | Header configuration. Usually used for especifying access tokens | `any` | - | ||
`fsOptions` | FileSaver.js config, can be set `autoBom` value | `FileSaverOptions` | - | ||
`success` | Download success callback | `EventEmitter<HttpResponse<Blob>>` | - | ||
`error` | Download error callback | `EventEmitter<any>` | - | ||
| Parameter | Description | Type | Default | | ||
| ----------- | ---------------------------------------------------------------- | ---------------------------------- | ------- | | ||
| `method` | Request method type | `string` | `GET` | | ||
| `url` | Request URL | `string` | - | | ||
| `fileName` | Filename when downloading | `string` | - | | ||
| `query` | Additional query parameters. Equivalent to `params` value | `string` | - | | ||
| `header` | Header configuration. Usually used for especifying access tokens | `any` | - | | ||
| `fsOptions` | FileSaver.js config, can be set `autoBom` value | `FileSaverOptions` | - | | ||
| `success` | Download success callback | `EventEmitter<HttpResponse<Blob>>` | - | | ||
| `error` | Download error callback | `EventEmitter<any>` | - | | ||
@@ -85,5 +95,3 @@ #### Custom HTTP type | ||
```html | ||
<button type="button" | ||
fileSaver | ||
[http]="onRemote('pdf', true)">Download PDF</button> | ||
<button type="button" fileSaver [http]="onRemote('pdf', true)">Download PDF</button> | ||
``` | ||
@@ -114,6 +122,6 @@ | ||
| Class Name | Description | | ||
| --- | ---- | | ||
| Class Name | Description | | ||
| ------------------------ | ------------------------------------------------------------------------------------- | | ||
| `filesaver__not-support` | Not [Supported Browsers](https://github.com/eligrey/FileSaver.js/#supported-browsers) | | ||
| `filesaver__disabled` | During http request | | ||
| `filesaver__disabled` | During http request | | ||
@@ -120,0 +128,0 @@ #### Configuring CommonJS dependencies |
@@ -1,2 +0,2 @@ | ||
import { ElementRef, EventEmitter } from '@angular/core'; | ||
import { ElementRef, EventEmitter, NgZone, OnDestroy, OnInit } from '@angular/core'; | ||
import { HttpClient, HttpResponse } from '@angular/common/http'; | ||
@@ -7,3 +7,4 @@ import { Observable } from 'rxjs'; | ||
import * as i0 from "@angular/core"; | ||
export declare class FileSaverDirective { | ||
export declare class FileSaverDirective implements OnInit, OnDestroy { | ||
private ngZone; | ||
private el; | ||
@@ -21,8 +22,12 @@ private fss; | ||
readonly error: EventEmitter<any>; | ||
constructor(el: ElementRef<HTMLButtonElement>, fss: FileSaverService, httpClient: HttpClient); | ||
private readonly destroy$; | ||
constructor(ngZone: NgZone, el: ElementRef<HTMLButtonElement>, fss: FileSaverService, httpClient: HttpClient); | ||
ngOnInit(): void; | ||
ngOnDestroy(): void; | ||
private getName; | ||
_click(): void; | ||
setDisabled(status: boolean): void; | ||
private setupClickListener; | ||
private emitIfHasObservers; | ||
static ɵfac: i0.ɵɵFactoryDeclaration<FileSaverDirective, never>; | ||
static ɵdir: i0.ɵɵDirectiveDeclaration<FileSaverDirective, "[fileSaver]", ["fileSaver"], { "method": "method"; "http": "http"; "query": "query"; "header": "header"; "url": "url"; "fileName": "fileName"; "fsOptions": "fsOptions"; }, { "success": "success"; "error": "error"; }, never, never, true, never>; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70459
583
141