Apply filter in the file uploads
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user