ngx-custom-form-error
Version:
This library makes showing errors in angular forms easier.
46 lines (45 loc) • 2.62 kB
TypeScript
import { ElementRef } from '@angular/core';
import { FormControlName } from '@angular/forms';
import { Observable } from 'rxjs';
import { CustomFormControlLabelDirective } from '../custom-form-label.directive';
import { IErrorConfig } from '../ngx-custom-form-error.model';
import * as i0 from "@angular/core";
export declare class NgxCustomFormErrorComponent {
config: IErrorConfig;
private _destroy$;
private defaultConfig;
constructor(config: IErrorConfig);
formControl: FormControlName;
/** This input `controlElement` is just for adding errorClass to the native element if config has addErrorClassToElement set to true*/
controlElement: ElementRef;
/** This input labelRef, is used to grab label from innerText of the element that has `cLabel` directive. */
labelRef: CustomFormControlLabelDirective;
required?: string | null;
maxlength?: string | null;
minlength?: string | null;
min?: string | null;
max?: string | null;
email?: string | null;
pattern?: string | null;
/** If onTouchedOnly flag is on, we only show errors after the form is touched and has errors */
onTouchedOnly: boolean;
/** It adds error class to the form-control element which you can use to style the element */
addErrorClassToElement: boolean;
/** Color of the error message */
errorTextColor: string;
/**Max Length count is used to show remaining letters in right hand side of form error area eg. [5 / 10] */
maxLengthCount: number;
/** `label` input can give label for the form error as input property in case `cLabel` directive is not used. */
label?: string | null;
errors$: Observable<null | string[]>;
private messages;
private errorClass;
ngAfterContentInit(): void;
init(): void;
/*** We compose messages object from user inputs and global config here, which will use to show the error */
initmessages(): void;
getErrors(): Observable<string[]>;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxCustomFormErrorComponent, [{ optional: true; }]>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxCustomFormErrorComponent, "c-form-error", never, { "required": "required"; "maxlength": "maxLength"; "minlength": "minLength"; "min": "min"; "max": "max"; "email": "email"; "pattern": "pattern"; "onTouchedOnly": "onTouchedOnly"; "addErrorClassToElement": "addErrorClassToElement"; "errorTextColor": "errorTextColor"; "maxLengthCount": "maxLengthCount"; "label": "label"; }, {}, ["formControl", "controlElement", "labelRef"], ["*"]>;
}