How to set default value in Select?
I am trying to create time- dropdown select with multiple options. At present. the selectedTimeOption correctly identifies if we choose an option from dropdown, but can't detect a value that I am trying to display initially from the Typescript.
I want to first display a predefined value in select box even before selection (it basically comes from another page)
How do I implement it?
Is there a problem with TS component or the html? If someone can explain with small working example on stackblitz.com , that would be helpful.
HTML:
<select
[value]="selectedTimeOption"
(valueChange)="setTime($event)"
>
<option
"let option of timeOfOptions"
[value]="option"
>
{{ option.label }}
</option>
</select>
TS:
timeOptions:TimeItems[] =[
{ label: '0:00', value: '0' },
{ label: '1:00', value: '1' },
{ label: '2:00', value: '2' },
];