How do I save form field validation rules in an array? What should replace /'''''HERE'''''/ with?
formfields: Array<Object> = [
{label: "Employer:", control: "employer", validations: "{requirederror: "employer.errors?.required && employer.dirty", notvaliderror: "employer.errors?.maxlength && employer.dirty"}"},
{label: "Phone:", control: "phone", validations: "{requirederror: "phone.errors?.required && phone.dirty", notvaliderror: "phone.errors?.pattern && phone.dirty"},
{label: "Email:", control: "email", validations: "{requirederror: "email.errors?.required && email.dirty", notvaliderror: "email.errors?.email && email.dirty"}"}
];
<div *ngFor="let formfield of formfields; let i = index">
<div class="labelandinput">
<label class="label">{{formfield.label}}</label>
<input class="input" formControlName="{{formfield.control}}">
<div class="formfielderror" *ngIf=" /'''''HERE'''''/ ">...</div>
<div class="formfielderror" *ngIf=" /'''''HERE'''''/ ">...</div>
</div>
</div>
Is it simply achieved like this?
<div class="formfielderror" *ngIf="{{formfield.validations.requirederror}}"> SOME REQUIRED ERROR </div>
<div class="formfielderror" *ngIf="{{formfield.validations.notvaliderror}}"> SOME NOT VALID ERROR </div>