Angular PrimeNG SplitButton Animation Configuration
Last Updated :
31 Jan, 2023
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:
- showTransitionOptions: It is used to set the transition options of the show animation. It is of string type and the default value is .12s cubic-bezier(0, 0, 0.2, 1).
- hideTransitionOptions: It is used to set the transition options of the hide animation. It is of string type and the default value is .1s linear.Â
Â
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.
HTML
< 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 >
|
Javascript
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' }
];
}
}
|
Javascript
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.
HTML
< 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 >
|
Javascript
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' }
];
}
}
|
Javascript
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
Share your thoughts in the comments
Please Login to comment...