aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.ts
blob: aadf13ebef8c99e9bb2c24225e6b31efb0be16d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {Component, ElementRef, Input, ViewChild} from "@angular/core";
import {FormGroup} from "@angular/forms";
import {FileFormControl} from "../../../../models/formControlModels/fileFormControl.model";

@Component({
  selector : 'file-form-control',
  templateUrl : './file.formControl.component.html',
  styleUrls : ['./file.formControl.component.scss']
})

export class FileFormControlComponent {
  @Input() data: FileFormControl = null;
  @Input() form: FormGroup;
  @ViewChild('fileUploader', {static: false})
  fileUploader:ElementRef ;

  onDelete(event, data, form) {
    event.stopPropagation();
    event.preventDefault();
    form.value[data.controlName] = this.fileUploader.nativeElement.value = "";
    data.selectedFile = data.placeHolder;
    if (data.onDelete){
      data.onDelete(form);
    }

  }
}