This commit is contained in:
Peter Maquiran
2021-08-23 16:01:07 +01:00
parent df8876f436
commit 52d5ff89c8
3 changed files with 35 additions and 9 deletions
+18 -2
View File
@@ -1,17 +1,27 @@
import { Injectable } from '@angular/core';
import { FileType } from 'src/app/models/fileType';
interface createInput {
type?: string
accept: typeof FileType[]
}
@Injectable({
providedIn: 'root'
})
export class FileLoaderService {
nice : typeof FileType
constructor() { }
createInput({ type = 'file'}): HTMLInputElement {
createInput(param:createInput): HTMLInputElement {
let input = document.createElement('input');
input.type = type;
input.type = param.type || 'file';
input.accept = param.accept.join(', ')
// input.onchange = () => {
// // you can use this method to get file and perform respective operations
@@ -24,4 +34,10 @@ export class FileLoaderService {
return input
}
getFirstFile(input: HTMLInputElement) {
let files = Array.from(input.files);
return files[0]
}
}