If you want to create a custom placeholder for your component, you can define a function like this:
getCustomPlaceholder(key: string): string
This function will dynamically generate the placeholder text based on the input key.
In your component template, you can then use this function like so:
<input class="input" formControlName="email" [placeholder]="getCustomPlaceholder('email')">
Another option is to extend the FormControl class by creating a custom class:
export class CustomFormControl extends FormControl {
_customPlaceholder: string
constructor(...config) {
super(config)
}
set customPlaceholder(key:string){
this._customPlaceholder = key
}
get customPlaceholder() {
return this._customPlaceholder
}
}
You can then add your custom form control to the FormGroup and access the custom placeholder using
form.controls['email'].customPlaceholder
.