Skip to content

Instantly share code, notes, and snippets.

View LalanaChami's full-sized avatar
:octocat:
working from home 🏛

Lalana Chamika LalanaChami

:octocat:
working from home 🏛
View GitHub Profile
@LalanaChami
LalanaChami / mime-type.validators.ts
Last active October 3, 2020 16:27
typescript mime type validator to a file picker in order pick png and jpg images
import { AbstractControl } from '@angular/forms';
import { Observable, Observer } from 'rxjs';
export const mimeType =(
control: AbstractControl
): Promise<{[key: string]:any}> | Observable<{[key: string]:any}> =>{
const file =control.value as File;
const fileReader = new FileReader();
const frObs = Observable.create((observer : Observer<{[key: string]:any}>)=>{
fileReader.addEventListener("loadend", ()=>{