I have a custom input component, just a cover for regular html input tag.
Here is a usage example:
<form [formGroup]="formGroup">
<my-input [title]="Some title" formControlName="name"></my-input>
</form>
And related component contains:
formGroup: FormGroup = new FormGroup({
name: new FormControl('', Validators.required),
});
I managed to access FormControl instance from within my-input component using this approach, now what I want to do, is to add an asterisk to my-input title if it is required.
The question is - is it possible to access list of validators so I can distinguish required validator among them?
P.S. Surely I can put required attribute on the element itself
<my-input ... required></my-input>
But I want use reactive forms.
<my-input [title]="Some title" [setRequired]="true" formControlName="name"></my-input>and get in child using@Input() setRequired: boolean. In html<span *ngIf="setRequired">*</span>ControlValueAccessorto useformControlNameon child?