Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


How to create radiobuttons in Angular
Here is the syntax to create radiobuttons in Angular:

<input type="radio" name="radiochoice" id="radio1" [value]="1" [(ngModel)]="choice" />
<input type="radio" name="radiochoice" id="radio2" [value]="2" [(ngModel)]="choice" />
<input type="radio" name="radiochoice" id="radio3" [value]="3" [(ngModel)]="choice" />

"name" must match to group them together.
"id" is required for the ngModel to bind.
"choice" can be accessed by {{choice}} or in the typescript (choice = 1 or choice = '1' depending on your data type).

Created By: amos 7/28/2023 11:13:20 PM