Angular PrimeNG Splitter Events
Last Updated :
02 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. In this article, we will see Angular PrimeNG Splitter Events.
The Splitter Component allows a user to split two-element using a splitter & utilized it separately and resize panels.Â
Angular PrimeNG Splitter Events:
- onResizeStart: It is a callback that is fired when resizing starts.
- onResizeEnd: It is a callback that is fired when resizing ends.
Â
Syntax:
<p-splitter (event)=function()>
...
</p-splitter>
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:
Â
Example 1: This example describes the basic usage of the Angular PrimeNG Splitter Events by implementing the onResizeStart event.
HTML
< div >
< h2 style = "color:green" >
GeeksforGeeks
</ h2 >
< h3 >
Angular PrimeNG Splitter Events
</ h3 >
< p-splitter [panelSizes]="[60, 40]"
[minSizes]="[20, 40]"
(onResizeStart)=onResizeStart()>
< ng-template pTemplate>
< div class="p-col p-ai-center
p-jc-center">
< img alt = "gfg"
src =
</ div >
</ ng-template >
< ng-template pTemplate>
< div class="p-col p-ai-center
p-jc-center">
< img alt = "gfg"
src =
</ div >
</ ng-template >
</ p-splitter >
</ div >
|
Javascript
import { Component } from "@angular/core" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html"
})
export class AppComponent {
onResizeStart() {
alert( "Resize started" )
}
}
|
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 { SplitterModule } from "primeng/splitter" ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
SplitterModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
|
Output:
Â
Example 2: This is another example that describes the use of the Angular PrimeNG Splitter Events by implementing the onResizeEnd event.
HTML
< div >
< h2 style = "color:green" >
GeeksforGeeks
</ h2 >
< h3 >Angular PrimeNG Splitter Events</ h3 >
< p-splitter [panelSizes]="[60, 40]"
[minSizes]="[20, 40]"
(onResizeEnd)=onResizeEnd()>
< ng-template pTemplate>
< div class = "p-col p-ai-center p-jc-center" >
< img alt = "gfg" src =
</ div >
</ ng-template >
< ng-template pTemplate>
< div class = "p-col p-ai-center p-jc-center" >
< img alt = "gfg" src =
</ div >
</ ng-template >
</ p-splitter >
</ div >
|
Javascript
import { Component } from "@angular/core" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html"
})
export class AppComponent {
onResizeEnd() {
alert( "Resize Ended" )
}
}
|
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 { SplitterModule } from "primeng/splitter" ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
SplitterModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
|
Output:
Â
Reference: https://primefaces.org/primeng/splitter
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...