projects/ng-dynamic-forms/core/src/lib/model/dynamic-form-value-control.model.ts
Properties |
|
Methods |
Accessors |
Protected
constructor(config: DynamicFormValueControlModelConfig
|
|||||||||
Parameters :
|
Private _value |
Type : T | null
|
Decorators :
@serializable('value')
|
additional |
Type : literal type | null
|
Decorators :
@serializable()
|
hint |
Type : string | null
|
Decorators :
@serializable()
|
required |
Type : boolean
|
Decorators :
@serializable()
|
tabIndex |
Type : number | null
|
Decorators :
@serializable()
|
Private Readonly value$ |
Type : BehaviorSubject<T>
|
Readonly valueChanges |
Type : Observable<T>
|
_disabled |
Type : boolean
|
Decorators :
@serializable('disabled')
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:28
|
asyncValidators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:27
|
controlTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:34
|
Private Readonly disabled$ |
Type : BehaviorSubject<boolean>
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:42
|
Readonly disabledChanges |
Type : Observable<boolean>
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:44
|
errorMessages |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:29
|
hidden |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:30
|
id |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:31
|
label |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:32
|
labelTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:33
|
layout |
Type : DynamicFormControlLayout | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:35
|
name |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:36
|
parent |
Type : DynamicPathable | null
|
Default value : null
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:37
|
relations |
Type : DynamicFormControlRelation[]
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:38
|
Abstract Readonly type |
Type : string
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:46
|
updateOn |
Type : DynamicFormHook | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:39
|
validators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:40
|
getAdditional | |||||||||
getAdditional(key: string, defaultValue?: any | null)
|
|||||||||
Parameters :
Returns :
any
|
toJSON |
toJSON()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:80
|
Returns :
any
|
value | ||||
getvalue()
|
||||
setvalue(value)
|
||||
Parameters :
Returns :
void
|
import { BehaviorSubject, Observable } from "rxjs";
import { DynamicFormControlModel, DynamicFormControlModelConfig } from "./dynamic-form-control.model";
import { DynamicFormControlLayout } from "./misc/dynamic-form-control-layout.model";
import { serializable } from "../decorator/serializable.decorator";
import { isBoolean, isObject } from "../utils/core.utils";
export interface DynamicFormValueControlModelConfig<T> extends DynamicFormControlModelConfig {
additional?: { [key: string]: any };
hint?: string;
required?: boolean;
tabIndex?: number;
value?: T;
}
export abstract class DynamicFormValueControlModel<T> extends DynamicFormControlModel {
@serializable() additional: { [key: string]: any } | null;
@serializable() hint: string | null;
@serializable() required: boolean;
@serializable() tabIndex: number | null;
@serializable("value") private _value: T | null;
private readonly value$: BehaviorSubject<T>;
readonly valueChanges: Observable<T>;
protected constructor(config: DynamicFormValueControlModelConfig<T>, layout?: DynamicFormControlLayout) {
super(config, layout);
this.additional = isObject(config.additional) ? config.additional : null;
this.hint = config.hint || null;
this.required = isBoolean(config.required) ? config.required : false;
this.tabIndex = config.tabIndex || null;
this.value$ = new BehaviorSubject(config.value !== null && config.value !== undefined ? config.value : null);
this.value$.subscribe(value => this._value = value);
this.valueChanges = this.value$.asObservable();
}
get value(): T | null {
return this.value$.getValue();
}
set value(value: T | null) {
this.value$.next(value);
}
getAdditional(key: string, defaultValue?: any | null): any {
return this.additional !== null && this.additional.hasOwnProperty(key) ? this.additional[key] : defaultValue;
}
}