Angular UI Components Documentation
The Angular RadioButtonGroup displays a check box group of items. This guide adds the Angular RadioButtonGroup (jqxRadioButtonGroup) to an app, then shows how to set its options and call its methods.
jqwidgets-ngjqwidgets-ng/jqxradiobuttongroup In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxRadioButtonGroupModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxRadioButtonGroupModule } from 'jqwidgets-ng/jqxradiobuttongroup';
@Component({
selector: 'app-root',
imports: [jqxRadioButtonGroupModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Radio Button Group (NEW) demo.
<jqxRadioButtonGroup [change]="change" [items]="items" layout="'vertical'" [value]="value" #group></jqxRadioButtonGroup>
<br/>
<div [innerHTML]="log"></div>
import { Component, viewChild } from '@angular/core';
import { jqxRadioButtonGroupComponent } from 'jqwidgets-ng/jqxradiobuttongroup';
import { CommonModule } from '@angular/common';
import { jqxRadioButtonGroupModule } from 'jqwidgets-ng/jqxradiobuttongroup';
@Component({
imports: [CommonModule, jqxRadioButtonGroupModule],
selector: 'app-root',
templateUrl: './app.html'
})
export class App {
readonly group = viewChild.required<jqxRadioButtonGroupComponent>('group');
log: string = '';
value: any = 'Volvo';
items: any[] = [
'Volvo',
{ enabled: true, encoded: false, label: '<i> Audi</i>', value: 'Audi' },
{ enabled: true, label: 'Mercedes', value: 'Mercedes' },
{ enabled: false, label: 'VW', value: 'Vw' },
{ enabled: true, cssClass: 'custom-class', label: 'Opel', value: 'Opel' }
];
change = (item: any) => {
const value = this.group().getValue();
this.log = `
<h3>Item Details</h3>
label: ${item.label}<br/>
value: ${item.value}<br/>
<h3>Value</h3>
${value}
`;
};
}
Options are inputs, bound with [name]="value".
Get the component with a signal query and call its methods. For example, val: Sets or gets the value.
<jqxRadioButtonGroup #myRadioButtonGroup></jqxRadioButtonGroup>
import { Component, viewChild } from '@angular/core';
import { jqxRadioButtonGroupModule, jqxRadioButtonGroupComponent } from 'jqwidgets-ng/jqxradiobuttongroup';
@Component({
selector: 'app-root',
imports: [jqxRadioButtonGroupModule],
templateUrl: './app.html'
})
export class App {
readonly myRadioButtonGroup = viewChild.required<jqxRadioButtonGroupComponent>('myRadioButtonGroup');
run(): void {
const value = this.myRadioButtonGroup().val();
console.log(value);
}
}