UNPKG

ng2-fileupload

Version:
78 lines (59 loc) 1.32 kB
# ng2-fileupload [![npm](https://img.shields.io/npm/v/ng2-fileupload.svg)](https://www.npmjs.com/package/ng2-fileupload) [![license](https://img.shields.io/github/license/thinkholic/ng2-fileupload.svg)](https://github.com/thinkholic/ng2-fileupload/blob/master/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/](http://localhost:4200/)