Open In App

Angular PrimeNG SplitButton Animation Configuration

Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. In this article, we will see how to use the SplitButton Animation Configuration Component in Angular PrimeNG. 

The SplitButton Component is used to make a button a dropdown.



Angular PrimeNG ConfirmPopup Animation Configuration properties:

 



Creating Angular Application And Installing Module:

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 the below code, we will make use of the above syntax to demonstrate the use of the SplitButton Animation Configuration Component.




<div style="text-align: center">
    <h2>GeeksforGeeks</h2>
    <h5
          Angular PrimeNG SplitButton 
          Animation Configuration Component
      </h5>
    <p-splitButton
      label="GeeksforGeeks"
      [showTransitionOptions]="'1500ms'"
      [model]="gfg">
      </p-splitButton>
</div>




import { Component, OnInit, ViewEncapsulation}
    from '@angular/core';
import {MenuItem} from 'primeng/api';
import {MessageService} from 'primeng/api';
  
@Component({
    selector: 'app-root',
    providers: [MessageService],
    templateUrl: './app.component.html',
    styles: [`
        :host ::ng-deep .ui-splitbutton {
            margin-right: .25em;
        }
    `]
})
  
export class AppComponent {
    gfg: MenuItem[];
      
    constructor(private messageService: MessageService) {}
      
    ngOnInit() {
        this.gfg = [
            {label: 'Angular'},
            {label: 'PrimeNG'},
            {label: 'SplitButton'}
        ];
    }
}




import { NgModule }     from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import {BrowserAnimationsModule}
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { SplitButtonModule } from 'primeng/splitbutton';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        SplitButtonModule,
        RouterModule.forRoot([
            {path:'',component: AppComponent}
        ])
    ],
    declarations: [ AppComponent ],
    bootstrap: [ AppComponent ]
})
  
export class AppModule { }

Output:

 

Example 2: In the below code, we will make use of the above syntax to demonstrate the use of the SplitButton Animation Configuration Component.




<div style="text-align: center">
    <h2>GeeksforGeeks</h2>
    <h5>
        Angular PrimeNG SplitButton 
        Animation Configuration Component.
    </h5>
    <p-splitButton
        label="GeeksforGeeks"
        [hideTransitionOptions]="'1500ms'"
        [model]="gfg">
    </p-splitButton>
</div>




import { Component, OnInit, ViewEncapsulation}
    from '@angular/core';
import {MenuItem} from 'primeng/api';
import {MessageService} from 'primeng/api';
  
@Component({
    selector: 'app-root',
    providers: [MessageService],
    templateUrl: './app.component.html',
    styles: [`
        :host ::ng-deep .ui-splitbutton {
            margin-right: .25em;
        }
    `]
})
  
export class AppComponent {
    gfg: MenuItem[];
    constructor(private messageService: MessageService) {}
      
    ngOnInit() {
        this.gfg = [
            {label: 'Angular'},
            {label: 'PrimeNG'},
            {label: 'SplitButton'}
        ];
    }
}




import { NgModule }     from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import {BrowserAnimationsModule}
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { SplitButtonModule } from 'primeng/splitbutton';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        SplitButtonModule,
        RouterModule.forRoot([
            {path:'',component: AppComponent}
        ])
    ],
    declarations: [ AppComponent ],
    bootstrap: [ AppComponent ]
})
  
export class AppModule { }

Output:

 

Reference: https://www.primefaces.org/primeng/splitbutton


Article Tags :