Skip to content

Directives

Alexey edited this page May 13, 2019 · 9 revisions

#Usage

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

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

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.
  • filesChange - Event that calling when you select a file(s), example: <input fileToText type="file" [(files)]="fileModelText" (filesChange)="onTextChanges($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