Angular PrimeNG时间线的相反内容

Angular PrimeNG时间线的相反内容

Angular PrimeNG是一个开源框架,它有丰富的原生Angular UI组件,可以用来做很好的造型,这个框架用来做响应式网站,非常方便。本文将向我们展示如何在Angular PrimeNG中使用时间线对立内容。我们还将了解这些属性,以及在代码中使用的语法。

时间线组件用于显示进程的时间线。

语法:

<p-timeline [value]="....">
    <ng-template pTemplate="content" let-event>
        ...
    </ng-template>
    <ng-template pTemplate="opposite" let-event>
         ...
    </ng-template>
</p-timeline>

Angular PrimeNG时间线的对立面内容属性:

  • value。它是一个要显示的事件数组。它是数组的数据类型,默认值为空。

创建Angular应用程序和模块安装。

第1步:使用以下命令创建一个Angular应用程序。

ng new appname

第2步:创建你的项目文件夹即appname后,使用以下命令移动到它。

cd appname

第3步在你给定的目录中安装PrimeNG。

npm install primeng --save
npm install primeicons --save

项目结构:它将看起来像如下。

Angular PrimeNG时间线的相反内容

运行应用程序的步骤:运行以下命令以查看输出。

ng serve --open

例子1:这是说明Angular PrimeNG Timeline Opposite Content.使用的基本例子代码。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Timeline Opposite Content</h5>
  
<p-timeline [value]="gfgCourse">
     <ng-template pTemplate="content" let-event>
         <small class="p-text-secondary">
             {{event.courseNumner}}
         </small>
     </ng-template>
  
     <ng-template pTemplate="opposite" let-event>
         {{event.courseName}}
     </ng-template>
</p-timeline>
  • app.component.ts:
import { Component } from '@angular/core';
import { PrimeIcons } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
})
  
export class AppComponent {
    gfgCourse: any[];
  
    ngOnInit() {
        this.gfgCourse = [
            {
                courseNumner: 'Course 1',
                courseName: 'DSA Self Paced',
            },
            {
                courseNumner: 'Course 2',
                courseName: 'C++ STL',
            },
            {
                courseNumner: 'Course 3',
                courseName: 'System Design',
            },
            {
                courseNumner: 'Course 4',
                courseName: 'Test Series',
            },
        ];
    }
}
  • app.module.ts:
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 { }

输出:

Angular PrimeNG时间线的相反内容

示例2:这是另一个示例代码,说明了Angular PrimeNG Timeline Opposite Content.的使用。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Timeline Opposite Content</h5>
  
<p-timeline [value]="gfgTutorial">
    <ng-template pTemplate="content" let-event>
        <small class="p-text-secondary">
           {{event.tutorialNumber}}
        </small>
    </ng-template>
  
    <ng-template pTemplate="opposite" let-event>
         {{event.tutorialName}}
    </ng-template>
</p-timeline>
  • app.component.ts:
import { Component } from '@angular/core';
import { PrimeIcons } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
})
  
export class AppComponent {
    gfgTutorial: any[];
  
    ngOnInit() {
         this.gfgTutorial = [
           {
             tutorialNumber: 'Tutorial 1',
             tutorialName: 'React Tutorial',
           },
           {
             tutorialNumber: 'Tutorial 2',
             tutorialName: 'Angular Tutorial',
           },
           {
             tutorialNumber: 'Tutorial 3',
             tutorialName: 'JavaScript Tutorial',
           },
           {
             tutorialNumber: 'Tutorial 4',
             tutorialName: 'C++ Tutorial',
           },
        ];
    }
}
  • app.module.ts:
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 {}

输出:

Angular PrimeNG时间线的相反内容

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程