I have a drop-down menu where I would like to set a value using some logic in my TS file. This is what my drop-down looks like:
<select [(ngModel)]="selectedEntity" (change)="onChange();">
<option *ngFor="let item of Entities" [ngValue]="item.EntityID">{{item.EntityName}}</option>
</select>
On change, I would like to check for a condition, and then set a value based on that condition. However, I'm stuck because I can't seem to get the drop-downs value to update in the view. I've tried to set the selectedEntity
to a new value, but no success. How would I be able to set the selected value using the TS file?
Edit: For more clarity, I'm basically trying to confirm whether the selected choice is allowed for the current item in the Entities array. If it is allowed, select the option the user picked, if not, reset it to the previous value.