0

In my Angular program, I want to default the option that's selected in my select to be "Current". In everything that I've seen online, what I have should work and it just defaults as null. I've also tried selected = "selected" and that doesn't work either. Why doesn't it and how do I fix it?

<select class="form-control" id="empStatus" [(ngModel)]="newEmp.EmpStat" name="empStatus">
    <option value="Current" selected>Current</option>
    <option value="Terminated">Terminated</option>
</select>
rcarcia02
  • 927
  • 4
  • 15
  • 46

1 Answers1

0

Try changing it to (if coding in XHTML file):

<select class="form-control" id="empStatus" [(ngModel)]="newEmp.EmpStat" name="empStatus">
<option value="Current" selected="selected">Current</option>
<option value="Terminated">Terminated</option>

As seen here: How can I set the default value for an HTML <select> element?

C. Lightfoot
  • 529
  • 1
  • 5
  • 24