Skip to content

Commit

Permalink
feat: improve the Event emit
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisam committed Apr 5, 2017
1 parent fd7dc41 commit 064feeb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/clipboard.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ export class ClipboardDirective implements OnInit, OnDestroy {

@Input() public cbContent: string;

@Output() public cbOnSuccess: EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() public cbOnSuccess: EventEmitter<any> = new EventEmitter<any>();

@Output() public cbOnError: EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() public cbOnError: EventEmitter<any> = new EventEmitter<any>();

constructor(public elmRef: ElementRef) { }

public ngOnInit() {
let option: Clipboard.Options;
option = !!this.targetElm ? { target: () => <any> this.targetElm } : { text: () => this.cbContent };
option = !!this.targetElm ? { target: () => <any>this.targetElm } : { text: () => this.cbContent };
this.clipboard = new Clipboard(this.elmRef.nativeElement, option);
this.clipboard.on('success', () => this.cbOnSuccess.emit(true));
this.clipboard.on('error', () => this.cbOnError.emit(true));
this.clipboard.on('success', (e) => this.cbOnSuccess.emit(e));
this.clipboard.on('error', (e) => this.cbOnError.emit(e));
}

public ngOnDestroy() {
Expand Down

0 comments on commit 064feeb

Please sign in to comment.