ng2-fileupload
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

ng2-fileupload

npm license

Simpler file upload implementation for angular2 apps.

Installation

npm install ng2-fileupload

Usage

example.module.ts

import { FileUpload } from 'ng2-fileupload';

@NgModule({
  declarations: [
    ExampleComponent,
    FileUpload
  ],
})

example.component.ts

export class ExampleComponent {
  allowedTypes: any;
  
  constructor() {
    this.allowedTypes = [ 'text/markdown' ];
  }

  onUploadFiles(evt: any) {
    if (evt.error) {
        throw evt.error;
    }

    const files = evt.files;
    // You can run upload script here
  }
}

example.component.html

<file-upload
  [allowedTypes]="allowedTypes"
  allowedSize="15" // MB
  (onUploadFiles)="onUploadFiles($event)"
>
</file-upload>

Contributing Guide

Setting up the development environment

git clone git@github.com:thinkholic/ng2-fileupload.git
cd ng2-fileupload
npm install
npm run build

Demo

npm install angular-cli -g
cd demo
ng serve

Demo app will be running on http://localhost:4200/

Readme

Keywords

Package Sidebar

Install

npm i ng2-fileupload

Weekly Downloads

51

Version

0.0.7

License

MIT

Last publish

Collaborators

  • thinkholic