kit-form-field

README

Scope

  • Forms styling and errors handling

API

[class] KitFormErrorDirective

@Directive

Selector:'[kitFormError]'

Structure directive for capturing form-error template.

Members

SignatureDescription
@Input() kitFormError: string
get name(): string

[class] KitFormFieldModule

@NgModule

Exports:[ KitFormErrorDirective, KitNgControlDirective, ]
Providers:[]

[class] KitFormFieldService

@Injectable

Example

Members

SignatureDescription
get control(): KitNgControlDirective
get controls(): KitNgControlDirective[]
add(control: KitNgControlDirective)

Register KitNgControlDirective in the service.

remove(control: KitNgControlDirective)
hasError(name: string)

Check if error exists.

getErrorsToDisplay(): string[]

Has any error and control touched or dirty.

isRequired(): boolean

Is main control required.

[class] KitNgControlDirective

@Directive

Selector:'[ngModel],[formControl],[formControlName]'

Registers control in KitFormFieldService.

Also generates unique _id (needed for correct working label in form-field).

Members

SignatureDescription
@Input() required: boolean
get id(): string
@Input() set id(id: string)
get errorStateChanges(): Observable<string[]>