Angular PrimeNG Timeline Properties
Last Updated :
07 Dec, 2022
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 TimeLine Properties in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.
The TimeLine Component is used to display the timeline of the process.
Angular PrimeNG Timeline Properties:
- value: It is an array of events to display. It is of array data type & the default value is null.
- align: It is the position of the timeline bar relative to the content. It is of string data type & the default value is left.
- layout: It is the orientation of the timeline. It is of string data type & the default value is vertical.
- style: It is the inline style of the component. It is of string data type & the default value is null.
- styleClass: It is the style class of the component. It is of string data type & the default value is null.
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
npm run
Example 1: Below is the example code that illustrates the use of the Angular PrimeNG Timeline Properties using the align property.
HTML
< h1 style = "color: green" >GeeksforGeeks</ h1 >
< h4 >Angular PrimeNG Timeline align Properties.</ h4 >
< h5 >Align = Left</ h5 >
< p-timeline [value]="gfg">
< ng-template pTemplate = "content" let-event>
{{event.status}}
</ ng-template >
</ p-timeline >
< h5 >Align = Right</ h5 >
< p-timeline [value]="gfg" align = "right" >
< ng-template pTemplate = "content" let-event>
{{event.status}}
</ ng-template >
</ p-timeline >
< h5 >Align = Alternate</ h5 >
< p-timeline [value]="gfg" align = "alternate" >
< ng-template pTemplate = "content" let-event>
{{event.status}}
</ ng-template >
</ p-timeline >
|
Javascript
import { Component } from "@angular/core" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html" ,
styleUrls: [ "./app.component.scss" ],
})
export class AppComponent {
gfg: any[];
ngOnInit() {
this .gfg = [
{
status: "Geek 1" ,
},
{
status: "Geek 2" ,
},
{
status: "Geek 3" ,
},
{
status: "Geek 4" ,
},
];
}
}
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserModule }
from '@angular/platform-browser' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { FormsModule } from '@angular/forms' ;
import { TimelineModule } from 'primeng/timeline' ;
import { CardModule } from 'primeng/card' ;
import { ButtonModule } from 'primeng/button' ;
import { AppComponent } from './app.component' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
ButtonModule,
TimelineModule,
CardModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
|
Output:
Example 2: Below is another example code that illustrates the use of the Angular PrimeNG Timeline Properties using the layout=”horizontal” property.
HTML
< h1 style = "color: green" >GeeksforGeeks</ h1 >
< h4 >Angular PrimeNG Timeline layout Properties.</ h4 >
< h6 >Align = Top</ h6 >
< p-timeline [value]="gfg" layout = "horizontal" align = "top" >
< ng-template pTemplate = "content" let-event>
{{event.status}}
</ ng-template >
</ p-timeline >
< h6 >Align = Bottom</ h6 >
< p-timeline [value]="gfg" layout = "horizontal" align = "bottom" >
< ng-template pTemplate = "content" let-event>
{{event.status}}
</ ng-template >
</ p-timeline >
< h6 >Align = Alternate</ h6 >
< p-timeline [value]="gfg" layout = "horizontal" align = "alternate" >
< ng-template pTemplate = "content" let-event>
{{event.status}}
</ ng-template >
</ p-timeline >
|
Javascript
import { Component } from "@angular/core" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html" ,
styleUrls: [ "./app.component.scss" ],
})
export class AppComponent {
gfg: any[];
ngOnInit() {
this .gfg = [
{
status: "Geek 1" ,
},
{
status: "Geek 2" ,
},
{
status: "Geek 3" ,
},
{
status: "Geek 4" ,
},
];
}
}
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserModule }
from '@angular/platform-browser' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { FormsModule } from '@angular/forms' ;
import { TimelineModule } from 'primeng/timeline' ;
import { CardModule } from 'primeng/card' ;
import { ButtonModule } from 'primeng/button' ;
import { AppComponent } from './app.component' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
ButtonModule,
TimelineModule,
CardModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
|
Output:
Reference: https://primefaces.org/primeng/timeline
Share your thoughts in the comments
Please Login to comment...