Apply filter in the file uploads

This commit is contained in:
Jose Alberto Hernandez
2022-11-25 08:18:14 -06:00
parent abe684eefa
commit 68a3cfb472
9 changed files with 49 additions and 35 deletions
@@ -14,4 +14,4 @@
</div>
<input type="file" #uploadFile (change)="onFileSelect($event)" [style.display]="'none'">
<input type="file" #uploadFile accept="{{acceptFilter}}" (change)="onFileSelect($event)" [style.display]="'none'">
@@ -1,5 +1,5 @@
/** Angular Imports */
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
/**
* Custom file upload component based on angular material.
@@ -9,15 +9,23 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
templateUrl: './file-upload.component.html',
styleUrls: ['./file-upload.component.scss']
})
export class FileUploadComponent {
export class FileUploadComponent implements OnInit {
/** Form field flex dimension */
@Input() flex: any;
@Input() acceptFilter: string;
/** Selected file name */
fileName: File;
constructor() { }
ngOnInit() {
if (!this.acceptFilter) {
this.acceptFilter = '.xls,.xlsx,.pdf,.doc,.docx,.png,.jpeg,.jpg';
}
}
/**
* Sets the file name.
* @param {any} event File input change event.