This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, forwardRef, Attribute, Injectable, ElementRef, Input } from '@angular/core'; | |
import { NG_VALIDATORS, Validator, AbstractControl, FormControl } from '@angular/forms'; | |
import { CustomValidators } from './customValidators'; | |
@Directive({ | |
selector: '[min][formControlName],[min][formControl],[min][ngModel]', | |
providers: [{ | |
provide: NG_VALIDATORS, | |
useExisting: forwardRef(() => MinValidator), | |
multi: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { AbstractControl } from '@angular/forms'; | |
@Injectable() | |
export class CustomValidators { | |
min(control: AbstractControl, value: number): { [key: string]: boolean } { | |
return control.value >= value ? null : { 'min': true }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clientsideDownloadFile = (blob,fileName) => { | |
// Test download attribute first | |
if ('download' in HTMLAnchorElement.prototype) { | |
// Create an object URL for the blob object | |
const url = URL.createObjectURL(blob); | |
// Create a new anchor element | |
const a = document.createElement('a'); | |
a.href = url; | |
a.download = fileName; |
OlderNewer