Angular PrimeNG Form MultiSelect Virtual Scrolling Component
Last Updated :
24 Apr, 2025
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use the Form MultiSelect Virtual Scrolling Component in Angular PrimeNG.
The Multiselect Component provides the user with a list of options where the user can select one or more options. The properties of the MultiSelect Component are listed below.
By displaying only a small portion of the data in the viewport at any given time, VirtualScrolling is an effective method for rendering the options. To avoid performance issues when dealing with a large number of options, VirtualScrolling should be enabled. Setting the virtualScroll property to true and defining the virtualScrollItemSize property to specify an item’s height is all that is required for use.
Syntax:
<p-multiSelect
[options]="..."
placeholder="..."
[virtualScroll]="true"
[filter]="..."
[itemSize]="...">
</p-multiSelect>
Angular PrimeNG Form MultiSelect Virtual Scrolling Properties:
- options: It is an array object representing select items to display as the available options. It is of array data type, the default value is null.
- virtualScroll: It is used to define the virtual scroll.
- virtualScrollItemSize: It is used to define the height of an item in the list for VirtualScrolling.
- filter: It is used to display an input field to filter the items on keyup.
Creating Angular application & module installation:
Step 1: Create an Angular application using the following command.
ng new appname
Step 2: After creating your project folder i.e. appname, move to it using the following command.
cd appname
Step 3: Install PrimeNG in your given directory.
npm install primeng --save
npm install primeicons --save
Project Structure: After completing the above processes, it will look like the following.
Steps to run the application: Run the below command to see the output
ng serve --save
Example 1: Below is the example code that illustrates the use of Angular PrimeNG Form MultiSelect Virtual Scrolling Component.
HTML
< h1 style = "color: green" >GeeksforGeeks</ h1 >
< h5 >Angular PrimeNG Form MultiSelect Virtual Scroll</ h5 >
< p-multiSelect
[options]="geeks"
placeholder = "Select any item Geek"
[virtualScroll]="true"
[filter]="true"
[itemSize]="34"
class = "multiselect-custom-virtual-scroll" >
</ p-multiSelect >
|
Javascript
import { Component } from "@angular/core" ;
import { SelectItem, PrimeNGConfig } from "primeng/api" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html" ,
styleUrls: [ "./app.component.scss" ],
})
export class AppComponent {
geeks: SelectItem[];
constructor()
{
this .geeks = [];
for (let i = 0; i < 10000; i++) {
this .geeks.push(
{
label: 'Item ' + i,
value: 'Item ' + i
}
);
}
}
}
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { AppComponent } from './app.component' ;
import {MultiSelectModule} from 'primeng/multiselect' ;
@NgModule({
imports: [
BrowserAnimationsModule,
MultiSelectModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
|
Output:
Example 2: Below is another example code that illustrates the use of Angular PrimeNG Form MultiSelect Virtual Scrolling Component using templating.
HTML
< h1 style = "color: green" >GeeksforGeeks</ h1 >
< h5 >Angular PrimeNG Form MultiSelect Virtual Scrolling</ h5 >
< p-multiSelect
[options]="geeks"
placeholder = "Search any Geek"
[virtualScroll]="true"
[filter]="true"
[itemSize]="34"
class = "multiselect-custom-virtual-scroll" >
< ng-template let-geek pTemplate = "item" >
< div class = "country-item" >
< div >{{ geek.label }}</ div >
</ div >
</ ng-template >
</ p-multiSelect >
|
Javascript
import { Component } from '@angular/core' ;
@Component({
selector: 'app-root' ,
templateUrl: './app.component.html' ,
styleUrls: [ './app.component.scss' ],
})
export class AppComponent {
geeks: any[];
constructor( ) {
this .geeks = [];
for (let i = 0; i < 10000; i++) {
this .geeks.push(
{
label: 'Geek ' + i,
value: 'Geek Name ' + i
}
);
}
}
}
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { AppComponent } from './app.component' ;
import {MultiSelectModule} from 'primeng/multiselect' ;
@NgModule({
imports: [
BrowserAnimationsModule,
MultiSelectModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
|
Output:
Reference: https://primefaces.org/primeng/multiselect
Similar Reads
Angular PrimeNG Form MultiSelect Template Mode Component
Angular PrimeNG is a free and open-source framework with various components that Angular developers can use in their applications to enhance the user experience and speed up the development as they do not have to write everything from the ground up. In this article, we will be discussing Angular Pri
4 min read
Angular PrimeNG Form MultiSelect Ellipsis Mode Component
Angular PrimeNG is a collection of hundreds of UI components that can be used by developers to speed up the development process of their Applications. It is developed by PrimeTek Informatics also known as PrimeFaces. In this article, we will be discussing Angular PrimeNG Form MultiSelect Ellipsis Mo
4 min read
Angular PrimeNG Form MultiSelect Chips Display Component
Angular PrimeNG is a free and open-source framework with various components that Angular developers can use in their applications to enhance the user experience and speed up the development as they do not have to write everything from the ground up. In this article, we will be discussing Angular Pri
4 min read
Angular PrimeNG Form MultiSelect Grouped Component
PrimeNG is an AngularJS component library developed by PrimeFaces. It provides developers to select from a wide range of already implemented themes and UI components for their applications. In this article, we will see the Angular PrimeNG Form MultiSelect Grouped Component. The MultiSelect Component
4 min read
Angular PrimeNG Form MultiSelect Advanced with Templating and Filtering Component
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use the Form MultiSelect Advanced with Templating and Filtering
4 min read
Angular PrimeNG Form MultiSelect Virtual Scrolling Component
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use the Form MultiSelect Virtual Scrolling Component in Angular
4 min read
Angular PrimeNG Form MultiSelect Value Binding Component
PrimeNG is an AngularJS component library developed by PrimeFaces. It provides developers to select from a wide range of already implemented themes and UI components for their applications. In this article, we will discuss the Angular PrimeNG Form MultiSelect Value Binding Component. The MultiSelect
5 min read
Angular PrimeNG Form MultiSelect Disabled Options Component
Angular PrimeNG is a collection of hundreds of UI components that can be used by developers to speed up the development process of their Applications. It is developed by PrimeTek Informatics also known as PrimeFaces. In this article, we will be seeing the Angular PrimeNG Form MultiSelect Disabled Op
4 min read
Angular PrimeNG Form MultiSelect Custom Content Component
Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will learn how to use the Angular PrimeNG Form MultiSelect Custom Content Compon
4 min read
Angular PrimeNG Form MultiSelect Animation Configuration Component
Angular PrimeNG is a free and open-source framework with various components that Angular developers can use in their applications to enhance the user experience and speed up the development as they do not have to write everything from the ground up. In this article, we will see the Angular PrimeNG F
4 min read