Skip to content

Instantly share code, notes, and snippets.

@djabif
Last active August 15, 2022 20:32
Show Gist options
  • Save djabif/952874969d3af3023beb16deac0659f8 to your computer and use it in GitHub Desktop.
Save djabif/952874969d3af3023beb16deac0659f8 to your computer and use it in GitHub Desktop.
<ng-container *ngFor="let control of jsonFormData?.controls">
<label class="block mt-6" for="{{ control.name }}">{{
control.label
}}</label>
<input
*ngIf="
[
'text',
'password',
'email',
'number',
'checkbox',
'tel',
'url'
].includes(control.type)
"
[type]="control.type"
[formControlName]="control.name"
[value]="control.value"
/>
<textarea
*ngIf="control.type === 'textarea'"
[formControlName]="control.name"
[value]="control.value"
></textarea>
<select
*ngIf="control.type === 'select'"
[formControlName]="control.name"
[value]="control.value"
>
<option *ngFor="let option of control.options" [value]="option">
{{ option }}
</option>
</select>
</ng-container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment