1

the radio button should be checked according to the value i get in the ngModel, the value that will get on ngModel will be 1 or 0

 <div class="col-md-6" id="radio-demo">
               <input type="radio" name="in_stock"   id="first-choice"  [(ngModel)]="fifthSector.in_stock"   />
           <label for="first-choice">Yes</label>

           <input type="radio" name="in_stock" id="second-choice"   [(ngModel)]="fifthSector.in_stock"   />
           <label for="second-choice">No</label>
             </div>

enter image description here

now i am getting both radio buttons not checked, how it can be done

1 Answer 1

2

You should use [value] directive. Try this:

<input name="options" type="radio" [value]="0"  [(ngModel)]="fifthSector.in_stock">Yes<br/>

<input name="options" type="radio" [value]="1" [(ngModel)]="fifthSector.in_stock" >No<br/>

Value:
{{fifthSector.in_stock}}

Stackblizt example: https://stackblitz.com/edit/angular-uhqd46

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.