I have some JSON data that contains a True/False value. Depending on whether it is true or false, I want a specific option in a Select Dropdown to be automatically selected.
This is the HTML code using Angular 16:
<select name="reportNo" id="reportNo" class="form-select" [(ngModel)]="reportInfo.active">
<option value="true"> Activated </option>
<option value="false"> Deactivated </option>
</select>
Here is an example of the JSON data:
"reportInfo": {
"active": true,
}
If the "active" value is true, then the option for "Activated" should be selected. Otherwise, if it is false, the "Deactivated" option should be selected.