exposes an event for file drop #130

Merged
mii9000 merged 1 commits from master into master 2016-05-12 12:56:25 +00:00
mii9000 commented 2016-04-02 10:52:21 +00:00 (Migrated from github.com)

Emits an event passing in raw File dropped.

Usage example:

<div ng2-file-drop
     [ngClass]="{'nv-file-over': hasBaseDropZoneOver}"
     (file-over)="fileOverBase($event)"
     [uploader]="uploader"
     (onFileDrop)="onFileDrop($event)"
     class="well my-drop-zone">
    Base drop zone
</div>
@Component({
  selector: 'simple-demo',
  template: template,
  directives: [FILE_UPLOAD_DIRECTIVES, NgClass, NgStyle, CORE_DIRECTIVES, FORM_DIRECTIVES]
})
export class SimpleDemo {
  private uploader:FileUploader = new FileUploader({url: URL});
  private hasBaseDropZoneOver:boolean = false;
  private hasAnotherDropZoneOver:boolean = false;

  private fileOverBase(e:any) {
    this.hasBaseDropZoneOver = e;
  }

  private fileOverAnother(e:any) {
    this.hasAnotherDropZoneOver = e;
  }

  onFileDrop(file: File) {
    //Do something with the file dropped
  }
}
Emits an event passing in raw `File` dropped. Usage example: ``` html <div ng2-file-drop [ngClass]="{'nv-file-over': hasBaseDropZoneOver}" (file-over)="fileOverBase($event)" [uploader]="uploader" (onFileDrop)="onFileDrop($event)" class="well my-drop-zone"> Base drop zone </div> ``` ``` js @Component({ selector: 'simple-demo', template: template, directives: [FILE_UPLOAD_DIRECTIVES, NgClass, NgStyle, CORE_DIRECTIVES, FORM_DIRECTIVES] }) export class SimpleDemo { private uploader:FileUploader = new FileUploader({url: URL}); private hasBaseDropZoneOver:boolean = false; private hasAnotherDropZoneOver:boolean = false; private fileOverBase(e:any) { this.hasBaseDropZoneOver = e; } private fileOverAnother(e:any) { this.hasAnotherDropZoneOver = e; } onFileDrop(file: File) { //Do something with the file dropped } } ```
valorkin commented 2016-05-12 12:19:17 +00:00 (Migrated from github.com)

all good, only one thing I will change while merging
this.onFileDrop.emit(transfer.files[0]); ->
this.onFileDrop.emit(transfer.files);

all good, only one thing I will change while merging `this.onFileDrop.emit(transfer.files[0]);` -> `this.onFileDrop.emit(transfer.files);`
valorkin commented 2016-05-12 12:56:36 +00:00 (Migrated from github.com)

Thanks for your help!

Thanks for your help!
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#130