Angular PrimeNG ScrollPanel Templates
Last Updated :
31 Jan, 2023
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. This article will show us how to use Angular PrimeNG ScrollPanel Templates.
The ScrollPanel Component is a lightweight, cross-browser replacement to the built-in browser scrollbar.
Angular PrimeNG ScrollPanel Templates: The templates are used to put some content on some pre-structured containers. ScrollPanel templates are discussed below:
- content: This template is used to create content for the ScrollPanel
Â
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: It will look like the following:
Â
Steps to run the application: Run the below command to see the output
ng serve --save
Example 1: In this example, we will see vertical scrolling of the Scroll Panel in Angular PrimeNG.
HTML
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >
Angular PrimeNG ScrollPanel Templates
</ h2 >
< p-scrollPanel [style]="{ height: '100px' }" pTemplate = "content" >
< p >
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
</ p >
< p >
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
</ p >
< p >
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
</ p >
</ p-scrollPanel >
|
Javascript
import { Component} from '@angular/core' ;
@Component({
selector: 'app-root' ,
templateUrl: './app.component.html'
})
export class AppComponent { }
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserModule } from '@angular/platform-browser' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { AppComponent } from './app.component' ;
import { ScrollPanelModule } from 'primeng/scrollpanel' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
ScrollPanelModule
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
|
Output:
Â
Example 2: In this example, we will see styling the content of the Scroll Panel in Angular PrimeNG.
HTML
< div style = "width: 60%;" >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >
Angular PrimeNG ScrollPanel Templates
</ h2 >
< p-scrollPanel [style]="{ height: '100px' }" pTemplate = "content" >
< p style = "color:'blue'" >
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
</ p >
< p style = "color:'red'" >
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
</ p >
< p style = "color:'green'" >
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
GeeksforGeeks is a Computer Science Portal.
</ p >
</ p-scrollPanel >
</ div >
|
Javascript
import { Component} from '@angular/core' ;
@Component({
selector: 'app-root' ,
templateUrl: './app.component.html'
})
export class AppComponent { }
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserModule } from '@angular/platform-browser' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { AppComponent } from './app.component' ;
import { ScrollPanelModule } from 'primeng/scrollpanel' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
ScrollPanelModule
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
|
Output:
Â
Reference: https://primefaces.org/primeng/scrollpanel
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...