Open In App

Angular PrimeNG Splitter Templates

Improve
Improve
Like Article
Like
Save
Share
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 know how to use the Splitter Templates in Angular PrimeNG.

The Splitter Component allows a user to split two-element using a splitter & utilized it separately and resize panels.

This article will show Splitter Templating in Angular PrimeNG. The templates are used to put some content on some pre-structured containers.

 

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: This is the basic example that illustrates how to use the Splitter Templates using horizontal Template.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Splitter Template</h5>
  
<p-splitter [style]="{ height: '300px' }" layout="horizontal">
    <ng-template pTemplate>
        <div class="p-col p-d-flex p-ai-center p-jc-center">
            GeeksforGeeks 1
        </div>
    </ng-template>
  
    <ng-template pTemplate>
        <div class="p-col p-d-flex p-ai-center p-jc-center">
              GeeksforGeeks 2
          </div>
    </ng-template>
</p-splitter>


  • app.component.ts:

Javascript




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {}


  • app.module.ts:

Javascript




import { NgModule } from "@angular/core";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { SplitterModule } from "primeng/splitter";
  
@NgModule({
    imports: [
        BrowserAnimationsModule,
        SplitterModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}


Output:

 

Example 2: This is another example that illustrates how to use the Splitter Templates using vertical Template.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Splitter Template</h5>
  
<p-splitter [style]="{ height: '300px' }" layout="vertical">
    <ng-template pTemplate>
        <div class="p-col p-d-flex p-ai-center p-jc-center">
            GeeksforGeeks 1
        </div>
    </ng-template>
  
    <ng-template pTemplate>
        <div class="p-col p-d-flex p-ai-center p-jc-center">
            GeeksforGeeks 2
        </div>
    </ng-template>
</p-splitter>


  • app.component.ts:

Javascript




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {}


  • app.module.ts:

Javascript




import { NgModule } from "@angular/core";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { SplitterModule } from "primeng/splitter";
  
@NgModule({
    imports: [
        BrowserAnimationsModule,
        SplitterModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}


Output:

 

Reference: https://primefaces.org/primeng/splitter



Last Updated : 31 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads