Angular UI Components Documentation
The Angular Button displays a clickable button with text, an image or both. This guide adds the Angular Button (jqxButton) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxbutton 
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 jqxButtonModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxButtonModule } from 'jqwidgets-ng/jqxbutton';
@Component({
selector: 'app-root',
imports: [jqxButtonModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Default Functionality demo.
<div style='margin-top: 20px'>
<jqxButton #button [width]='120' [height]='40' (onClick)="buttonClicked()">
Button
</jqxButton>
</div>
<div style='margin-top: 20px'>
<jqxButton #submitButton [width]='120' [height]='40' (onClick)="submitButtonClicked()">
Submit
</jqxButton>
</div>
<div style='margin-top: 20px'>
<jqxButton #imageButton [width]='120' [height]='40'
[imgSrc]='"https://www.jqwidgets.com/angular/images/facebook.png"' (onClick)="imageButtonClicked()">
</jqxButton>
</div>
<div style='margin-top: 20px'>
<jqxButton #textImageButton [width]='120' [height]='40'
[textImageRelation]='"imageBeforeText"' [textPosition]='"left"' [imgSrc]='"https://www.jqwidgets.com/angular/images/twitter.png"'
(onClick)="textImageButtonClicked()">
Button
</jqxButton>
</div>
<div style='margin-top: 20px'>
<jqxButton #htmlButton [width]='120' [height]='40' (onClick)="hTMLButtonClicked()">
<span style='font-weight: bold;'>HTML Button</span>
</jqxButton>
</div>
<div style='margin-top: 20px'>
<jqxButton #disabledButton [width]='120' [height]='40' [disabled]='true'>
Disabled
</jqxButton>
</div>
<div style='margin-top:1em'>Events:</div>
<div #events></div>
import { Component, ElementRef, viewChild } from '@angular/core';
import { jqxButtonComponent } from 'jqwidgets-ng/jqxbuttons';
import { CommonModule } from '@angular/common';
import { jqxButtonModule } from 'jqwidgets-ng/jqxbuttons';
@Component({
imports: [CommonModule, jqxButtonModule],
selector: 'app-root',
templateUrl: './app.html'
})
export class App {
readonly myTextImageButton = viewChild.required<jqxButtonComponent>('textImageButton');
readonly myHTMLButton = viewChild.required<jqxButtonComponent>('htmlButton');
readonly events = viewChild.required<ElementRef>('events');
buttonClicked(): void {
this.events().nativeElement.innerHTML = '<span>Button Clicked</span>';
}
submitButtonClicked(): void {
this.events().nativeElement.innerHTML = '<span>Submit Button Clicked</span>';
}
imageButtonClicked(): void {
this.events().nativeElement.innerHTML = '<span>Image Button Clicked</span>';
}
textImageButtonClicked(): void {
this.events().nativeElement.innerHTML = '<span>Text/Image Button Clicked</span>';
this.myTextImageButton().setOptions({
textImageRelation: 'textBeforeImage',
imgPosition: 'left',
textPosition: 'center'
});
}
hTMLButtonClicked(): void {
this.events().nativeElement.innerHTML = '<span>HTML Button Clicked</span>';
this.myHTMLButton().value(
"<span style='font-style: italic; position: relative; right: 8px'>Thanks for clicking me!</span>"
);
}
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, click: This event is triggered when the button is clicked.
<jqxButton (onClick)="onClick($event)"></jqxButton>
onClick(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, val: Sets or gets the value.
<jqxButton #myButton></jqxButton>
import { Component, viewChild } from '@angular/core';
import { jqxButtonModule, jqxButtonComponent } from 'jqwidgets-ng/jqxbutton';
@Component({
selector: 'app-root',
imports: [jqxButtonModule],
templateUrl: './app.html'
})
export class App {
readonly myButton = viewChild.required<jqxButtonComponent>('myButton');
run(): void {
const value = this.myButton().val('New Text');
console.log(value);
}
}