Angular UI Components Documentation
The Angular ScrollBar provides a scroll bar that has a sliding thumb whose position corresponds to a value. This guide adds the Angular ScrollBar (jqxScrollBar) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxscrollbar 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 jqxScrollBarModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxScrollBarModule } from 'jqwidgets-ng/jqxscrollbar';
@Component({
selector: 'app-root',
imports: [jqxScrollBarModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Default Functionality demo.
<div style="margin-bottom: 10px;" #VerticalDiv>Vertical</div>
<jqxScrollBar (onValueChanged)="onValueChangedVertical($event)"
[width]="18" [height]="280"
[min]="0" [max]="1000" [vertical]="true">
</jqxScrollBar>
<div style="margin: 10px 0;" #HorizontalDiv>Horizontal</div>
<jqxScrollBar (onValueChanged)="onValueChangedHorizontal($event)"
[width]="280" [height]="18"
[min]="0" [max]="1000">
</jqxScrollBar>
import { Component, ElementRef, viewChild } from '@angular/core';
import { CommonModule } from '@angular/common';
import { jqxScrollBarModule } from 'jqwidgets-ng/jqxscrollbar';
@Component({
imports: [CommonModule, jqxScrollBarModule],
selector: 'app-root',
templateUrl: './app.html'
})
export class App {
readonly HorizontalDiv = viewChild.required<ElementRef>('HorizontalDiv');
readonly VerticalDiv = viewChild.required<ElementRef>('VerticalDiv');
onValueChangedVertical(event: any): void {
this.VerticalDiv().nativeElement.innerHTML =
'Vertical (' + parseInt(event.currentValue) + ')';
}
onValueChangedHorizontal(event: any): void {
this.HorizontalDiv().nativeElement.innerHTML =
'Horizontal (' + parseInt(event.currentValue) + ')';
}
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, valueChanged: This event is triggered when the value is changed.
<jqxScrollBar (onValueChanged)="onValueChanged($event)"></jqxScrollBar>
onValueChanged(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, isScrolling: Returns true, if the user is scrolling.
<jqxScrollBar #myScrollBar></jqxScrollBar>
import { Component, viewChild } from '@angular/core';
import { jqxScrollBarModule, jqxScrollBarComponent } from 'jqwidgets-ng/jqxscrollbar';
@Component({
selector: 'app-root',
imports: [jqxScrollBarModule],
templateUrl: './app.html'
})
export class App {
readonly myScrollBar = viewChild.required<jqxScrollBarComponent>('myScrollBar');
run(): void {
const result = this.myScrollBar().isScrolling();
console.log(result);
}
}