projects/commons/src/lib/elements/email/components/email.component.ts
| selector | cmn-email |
| styleUrls | ./email.component.scss |
| templateUrl | ./email.component.html |
Properties |
|
Methods |
|
Inputs |
constructor(viewRef: ViewContainerRef)
|
||||||
|
Parameters :
|
| forceError | |
Type : boolean
|
|
| icon | |
Type : string
|
|
| label | |
Type : string
|
|
| name | |
Type : string
|
|
| placeholder | |
Type : string
|
|
| size | |
Type : string
|
|
| Public ngOnInit |
ngOnInit()
|
|
Returns :
void
|
| Protected addFormValidator | ||||||||||||||||
addFormValidator(name: string, validators: Validators, value: string)
|
||||||||||||||||
|
Inherited from
Field
|
||||||||||||||||
|
Defined in
Field:17
|
||||||||||||||||
|
Parameters :
Returns :
void
|
| Public ngOnInit |
ngOnInit()
|
|
Inherited from
Field
|
|
Defined in
Field:9
|
|
Returns :
void
|
| Public form |
Type : FormGroup
|
|
Inherited from
Field
|
|
Defined in
Field:5
|
import { Validators } from '@angular/forms';
import { Component, Input, OnInit, ViewContainerRef } from '@angular/core';
import { emailValidator } from '../validators';
import { Field } from '../../../core/field/abstract';
@Component({
selector: 'cmn-email',
templateUrl: './email.component.html',
styleUrls: [ './email.component.scss', ],
})
export class EmailComponent extends Field implements OnInit {
@Input() public readonly name: string;
@Input() public readonly size: string;
@Input() public readonly icon: string;
@Input() public readonly label: string;
@Input() public readonly forceError: boolean;
@Input() public readonly placeholder: string;
constructor(private readonly viewRef: ViewContainerRef) {
super(viewRef);
}
public ngOnInit(): void {
super.ngOnInit();
this.addFormValidator(this.name, [ Validators.required, emailValidator ]);
}
}
<div class="field">
<label class="label"
*ngIf="label">
{{ label }}
</label>
<cmn-input [name]="name"
[size]="size"
[forceError]="forceError"
[placeholder]="placeholder"
[iconRight]="icon"
[formGroup]="form"
type="text">
</cmn-input>
</div>
./email.component.scss