Reputation: 591
I'm facing the the following error.
And when I click at the line pointed with BLUE ARROW in the above image, it points to of
of ngFor loop
in my html template.
<div class="w-[60%]">
<select
name="duration"
id=""
class="text-[1rem] leading-6 py-2 px-8 border border-[#BCBCBC] w-[27.875rem] rounded-md focus:outline-none focus:border-primary"
[formControl]="demoLength"
required
>
<option
[value]="timing.value"
*ngFor="let timing of staticDurationArray"
selected="{{ timing.selected }}"
>
{{ timing.time }}
</option>
</select>
</div>
And in the above code the staticDurationArray
is an array with static data in TS file
staticDurationArray = [
{
time: '15 min',
value: 15,
selected: '',
},
{
time: '30 min',
value: 30,
selected: '',
},
{
time: '45 min',
value: 45,
selected: '',
},
{
time: '1 hr',
value: 60,
selected: '',
},
]
Upvotes: 2
Views: 4820
Reputation: 591
I found the answer I tried by putting an *ngIf
condition to my piece of code and the issue is solved
<div class="w-[60%]">
<select
*ngIf="demoLength"
[formControl]="demoLength"
name="duration"
id=""
class="text-[1rem] leading-6 py-2 px-8 border border-[#BCBCBC] w-[27.875rem] rounded-md focus:outline-none focus:border-primary"
required
>
<option
[value]="timing.value"
*ngFor="let timing of staticDurationArray"
selected="{{ timing.selected }}"
>
{{ timing.time }}
</option>
</select>
</div>
Upvotes: 3