In my angular (2) application I have contacts which have a list of properties (fields). Each property has its own type like Date, Gender, String, Int etc.
In the editor for contacts I render specific form elements according to the type of the field. Date picker for date, radio groups for gender etc.
To do this I now have a (rather large) switch statement on the type of the field where each case is a specific form element/component.
<ng-container [formGroup]="formGroup" [ngSwitch]="field.fieldType">
<sp-contact-field-checkbox-list *ngSwitchCase="ContactFieldType.SET" [formControlName]="formControlName" [options]="field.options"></sp-contact-field-checkbox-list>
<div *ngSwitchCase="ContactFieldType.GENDER">
<sp-gender-input [id]="formControlName" [formControlName]="formControlName"></sp-gender-input>
</div>
...
In another component I show a details view of the contact. There I have a similar switch case so each of the property values is rendered correctly.
I feel like having these large switch statements in the HTML might be a anti pattern or bad design. Adding/changing property types needs to be done in multiple files.
Does anyone have a nicer (angular) solution to this problem? It feels like there should be a polymorphic solution but I can't do it in angular.