Skip to content

Directives

Alexey edited this page May 31, 2019 · 9 revisions

Usage

import { FctrlxAngularFileReader } from 'fctrlx-angular-file-reader';

@NgModule({
  ...
  imports: [
    ...,
    FctrlxAngularFileReader,
  ]
})
export class AppModule { }

use one of the availabe directive in a template like:

<input fileToText type="file" [(files)]="fileModelText" (filesChange)="onTextChanges($event)">

Available Directives

  • fileToBase64
  • fileToArrBuf
  • fileToText

Events and attributes.

  • files - your model that will be converted.
  • type - directives working only with type=file.
  • multiple - if you input is multiple - you will get in response array of files, in other case it will be an object.
  • onError - Handle Error event.
  • onAbort - This event is triggered each time the reading operation is aborted
  • onProgress - You can track parsing progress by this event (return %done).
  • filesChange - Event that calling when you select a file(s), example:
<input fileToText type="file" [(files)]="fileModelText" (filesChange)="onTextChanges($event)" (onError)="handleError($event)" (onProgress)="handleProgress($event)">

Response

Value that accepted to [(files)])

{
   name: string;//file name
   size: number;//file size 
   type: string;//file type
   base64?: string;//base64 data
   text?: string;//text data
   arrBuf?: any;//array buffer data
 }
Clone this wiki locally