Open In App

Angular PrimeNG Splitter Events

Last Updated : 26 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

  • app.component.html
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=
"https://media.geeksforgeeks.org/wp-content/uploads/20220807104303/dsaselfpacedcourseoverviewimage-300x289.png" />
            </div>
        </ng-template>

        <ng-template pTemplate>
            <div class="p-col p-ai-center 
                        p-jc-center">
                <img alt="gfg" 
                     src=
"https://media.geeksforgeeks.org/wp-content/uploads/20220807104255/completeinterviewpreparationcourseoverviewimage-300x289.png" />
            </div>
        </ng-template>
    </p-splitter>
</div>
  • app.component.ts
JavaScript
import { Component } from "@angular/core";

@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
export class AppComponent {
    onResizeStart() {
        alert("Resize started")
    }
}
  • app.module.ts
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.

  • app.component.html
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=
"https://media.geeksforgeeks.org/wp-content/uploads/20220807104303/dsaselfpacedcourseoverviewimage-300x289.png" />
            </div>
        </ng-template>

        <ng-template pTemplate>
            <div class="p-col p-ai-center p-jc-center">
                <img alt="gfg" src=
"https://media.geeksforgeeks.org/wp-content/uploads/20220807104255/completeinterviewpreparationcourseoverviewimage-300x289.png" />
            </div>
        </ng-template>
    </p-splitter>
</div>
  • app.component.ts
JavaScript
import { Component } from "@angular/core";

@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
export class AppComponent {
    onResizeEnd() {
        alert("Resize Ended")
    }
}
  • app.module.ts
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


Next Article

Similar Reads