Okay, bear with me I'm not going to make the code for you I will just give an example with some text.
So what you do is you make a consistent JSON.
fields = [
{key: 'abc', type 'text'},
{key: 'abc', type 'text'},
{key: 'abc', type 'text'},
{key: 'abc', type 'choosen', fields: [
{key: 'abcd', type 'text'},
{key: 'abc', type 'choosen', fields: [
{key: 'abcde', type 'text'}
]}
]}
]
Ok now we have an JSON array that can have multiple layers.
Now for every level you going to make one component in your maincomponent:
<div *ngFor="let field of fields">
<div *ngIf="field.key !== choosen">
<-- what ever you want to do with key put here -->
<subFields [data]="field.fields" (returnData)="returnData($event)" *ngIf="field.key === choosen"><subfields>
The @Input() data: any; will be your next fields in your child component. And @Output() returnData: EventEmitter<any> = new EventEmitter<any>(); to send data back to your parent.
The html of your child component will look like:
<div *ngFor="let field of data">
<div *ngIf="field.key !== choosen">
<-- what ever you want to do with key put here -->
<subFields [data]="field.fields" (returnData)="returnData($event)" *ngIf="field.key === choosen"><subfields>