I was having some problem when trying to pre-select Angular dropdown item based on value in typescript. Here is my typescript:
transferFeeTblCombBxRowIndex : any;
if (arborSvcTy.trim() === '501') {
this.transferFeeTblCombBxRowIndex = '1';
} else {
console.log("COME IN ELSE");
this.transferFeeTblCombBxRowIndex = '0';
}
In my html, I am trying to use two-way binding:
<td>
<select class="form-control" name="transferFeeTblCombBxRow" [(ngModel)]="transferFeeTblCombBxRow" [disabled]="isTransferFeeTblCombBxRowDisabled">
<option disabled value="transferFeeTblCombBxRowIndex == '0'">-- Please Select --</option>
<option value="transferFeeTblCombBxRowIndex == '1'">Charged</option>
<option value="transferFeeTblCombBxRowIndex == '2'">Waived</option>
</select>
</td>
I managed to print out the "COME IN ELSE" from the console. However, the dropdown is not pre-selected at the first item.
Any ideas? Thanks!