The CheckBox component for Angular represents a check box that allows the end-user to select a true, false or indeterminate condition.
npm install -g @angular/cli ng new jqwidgets-project cd jqwidgets-project
ng add jqwidgets-ng
jQWidgets UI for Angular is distributed as jqwidgets-ng NPM package
npm install jqwidgets-ng
@import 'jqwidgets-ng/jqwidgets/styles/jqx.base.css';
"styles": [ "node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css" ]
<div style='font-family: Verdana Arial; font-size: 12px; width: 400px;'>
<div style='float: left; width: 400px;'>
<h3 style='margin-left: 15px;'>Categories</h3>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
Entertainment
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25' [checked]='true'>
<span>Computers</span>
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
<span>Sports</span>
</jqxCheckBox>
</div>
<div style='float: left; width: 400px; margin-top: 10px;'>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
Health
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
<span>Finance</span>
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
<span>Travel</span>
</jqxCheckBox>
</div>
<div style='float: left; width: 400px; margin-top: 10px;'>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
Music
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
<span>Technology</span>
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25'>
<span>Publishing</span>
</jqxCheckBox>
</div>
<br />
<div style='float: left; width: 400px; margin-top: 10px;'>
<h3 style='margin-left: 15px;'>States</h3>
<jqxCheckBox [theme]="'fluent'" (onChange)="checkBox10OnChange($event)" style='margin-left: 10px; float: left;'
[width]='120' [height]='25' [checked]='true'>
<span #span10>Checked</span>
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" (onChange)="checkBox11OnChange($event)" style='margin-left: 10px; float: left;'
[width]='120' [height]='25' [checked]='false'>
<span #span11>Unchecked</span>
</jqxCheckBox>
</div>
<div style='float: left; width: 400px; margin-top: 10px;'>
<jqxCheckBox [theme]="'fluent'" (onChange)="checkBox12OnChange($event)" style='margin-left: 10px; float: left;'
[width]='120' [height]='25' [hasThreeStates]='true' [checked]='null'>
<span #span12>Indeterminate</span>
</jqxCheckBox>
<jqxCheckBox [theme]="'fluent'" style='margin-left: 10px; float: left;'
[width]='120' [height]='25' [disabled]='true'>
<span>Disabled</span>
</jqxCheckBox>
</div>
</div>
import { Component, ViewChild, ElementRef } from '@angular/core';
import { jqxCheckBoxModule, jqxCheckBoxComponent } from 'jqwidgets-ng/jqxcheckbox';
@Component({
selector: 'app-root',
imports: [jqxCheckBoxModule],
standalone: true,
templateUrl: './app.component.html'
})
export class AppComponent {
@ViewChild('span10') span10: ElementRef;
@ViewChild('span11') span11: ElementRef;
@ViewChild('span12') span12: ElementRef;
checkBox10OnChange(event: any): void {
let checked = event.args.checked;
if (checked) {
this.span10.nativeElement.innerHTML = 'Checked';
}
else {
this.span10.nativeElement.innerHTML = 'Unchecked';
}
}
checkBox11OnChange(event: any): void {
let checked = event.args.checked;
if (checked) {
this.span11.nativeElement.innerHTML = 'Checked';
}
else {
this.span11.nativeElement.innerHTML = 'Unchecked';
}
}
checkBox12OnChange(event: any): void {
let checked = event.args.checked;
if (checked) {
this.span12.nativeElement.innerHTML = 'Checked';
}
else if (false == checked) {
this.span12.nativeElement.innerHTML = 'Unchecked';
}
else {
this.span12.nativeElement.innerHTML = 'Indeterminate';
}
}
}