I am currently working on a form that is read-only and showcases data retrieved upon loading the page. One of the sections in this form includes an IsActive dropdownlist with options True or False. I have set up my model property isActive to bind with the boolean value retrieved from the database during the ngOnInit phase. My aim is to display the model value along with its corresponding dropdown selection. For instance, if the IsActive flag is true, I want the true option in the dropdown to be pre-selected when the page loads.
Here is the HTML code snippet:
<label class="col-md-2 col-form-label">Is Active</label>
<div class="col-md-10">
<select id="IsActive" name="IsActive" class="form-control" [(ngModel)]="selectedAccount.isActive" [disabled]="!isEditable">
<option [value]="1">True</option>
<option [value]="0">False</option>
</select>
</div>
However, the above code results in a blank selected option upon page load, only revealing the true and false options once clicked.