Here is a data type example:
export interface TYPE_A {
valueType: TYPE_A_VALUE_TYPES;
value: string | string[];
}
export enum TYPE_A_VALUE_TYPES {
singleValue = "singleValue",
multiValue = "multiValue",
}
In my component, I am using TYPE_A
for @Input
:
@Input() inputData: TYPE_A[] = [];
This is how it's implemented in the HTML:
<div class="feildContainer" *ngFor="let input of inputData">
<div class="singleFeild" *ngIf="input.valueType == 'singleValue'">
...
</div>
<div class="multiFeild" *ngIf="input.valueType == 'multiValue'">
<other-component *ngFor="let valueData of input.value"></other-component>
<div>
</div>
An error message appears in vscode
:
NgForOf<string | string[], NgIterable<string | string[]>>.ngForOf: NgIterable<string | string[]> | null | undefined
Although I understand why this error occurs, I am seeking the optimal resolution.