I am working on a dropdown menu that contains numbers ranging from 1 to 10.
Below is the HTML code for it:
<div class="form-group">
<label>{{l("RoomNumber")}}</label>
<p-dropdown [disabled] = "!roomNumbers.length" [options]="roomNumbers" autoWidth="false" [style]="{'width':'100%'}" name="numberRoom" [autoWidth]="true" [(ngModel)]="room.roomNumber"></p-dropdown>
</div>
This is how I populate the dropdown:
getRoomNumber(): void {
for (let i = 1; i <= 10; i++) {
this.roomNumbers.push({label: i.toString(), value: i});
}
}
When I save the selection to the database, for example, I get '2'.
During editing, I need to repopulate the dropdown with these numbers and pre-select the number saved in the database. How can I achieve this?