Hello. I have a status field. I want to do this if the value 1 then the second option is 0. When I open the modal, everything shows correctly, and when I change the value it does not work correctly. Here is the code and picture before and after. I will be very grateful.

<select #status="ngModel" [(ngModel)]="category.status" class="form-control"> <option>{{category.status}}</option> <option *ngIf="category.status === 1">0</option> <option *ngIf="category.status === 0">1</option> </select> 

Before

After

    1 answer 1

    Try:

     <select #status="ngModel" [(ngModel)]="category.status" class="form-control"> <option [selected]="category.status === 1">0</option> <option [selected]="category.status === 0">1</option> </select> 
    • works. thank. but can it be done so that in the opening option there is no value that already stands? Example prntscr.com/helzpv - Ara Chinaryan