file upload is added
This commit is contained in:
parent
a880e89ba4
commit
feb398b6d9
|
@ -5,9 +5,16 @@
|
||||||
fxLayoutAlign="center center"
|
fxLayoutAlign="center center"
|
||||||
>
|
>
|
||||||
<div class="add-option">
|
<div class="add-option">
|
||||||
<button mat-icon-button class="material-icons">
|
<button mat-icon-button class="material-icons" (click)="onClickFileInput()">
|
||||||
<mat-icon>attach_file</mat-icon>
|
<mat-icon>attach_file</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
#fileInput
|
||||||
|
style="display: none"
|
||||||
|
multiple
|
||||||
|
(change)="onChangeFileInput()"
|
||||||
|
/>
|
||||||
|
|
||||||
<button mat-icon-button class="material-icons">
|
<button mat-icon-button class="material-icons">
|
||||||
<mat-icon>sentiment_satisfied_alt</mat-icon>
|
<mat-icon>sentiment_satisfied_alt</mat-icon>
|
||||||
|
|
|
@ -3,7 +3,8 @@ import {
|
||||||
OnInit,
|
OnInit,
|
||||||
Output,
|
Output,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
ViewChild
|
ViewChild,
|
||||||
|
ElementRef
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NgForm } from '@angular/forms';
|
import { NgForm } from '@angular/forms';
|
||||||
|
|
||||||
|
@ -16,9 +17,15 @@ export class FormComponent implements OnInit {
|
||||||
@Output()
|
@Output()
|
||||||
send = new EventEmitter<string>();
|
send = new EventEmitter<string>();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
sendFiles = new EventEmitter<File[]>();
|
||||||
|
|
||||||
@ViewChild('replyForm', { static: false })
|
@ViewChild('replyForm', { static: false })
|
||||||
replyForm: NgForm;
|
replyForm: NgForm;
|
||||||
|
|
||||||
|
@ViewChild('fileInput', { static: false })
|
||||||
|
fileInput: ElementRef<HTMLInputElement>;
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
ngOnInit() {}
|
ngOnInit() {}
|
||||||
|
@ -29,4 +36,16 @@ export class FormComponent implements OnInit {
|
||||||
this.send.emit(this.replyForm.form.value.message);
|
this.send.emit(this.replyForm.form.value.message);
|
||||||
this.replyForm.reset();
|
this.replyForm.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClickFileInput() {
|
||||||
|
this.fileInput.nativeElement.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeFileInput() {
|
||||||
|
const files: File[] = [];
|
||||||
|
for (let i = 0; i < this.fileInput.nativeElement.files.length; i++) {
|
||||||
|
files.push(this.fileInput.nativeElement.files.item(i));
|
||||||
|
}
|
||||||
|
this.sendFiles.emit(files);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user