Angular PrimeNG分割器内容

Angular PrimeNG分割器内容

Angular PrimeNG是一个开源框架,拥有丰富的原生Angular UI组件,可以用来做很好的造型,这个框架用来制作响应式网站非常方便。本文将告诉我们如何在Angular PrimeNG中使用Divider组件。我们还将学习一些属性,以及在代码中使用的语法。

分割器组件是用来制作一个使用分割器分割内容的组件。任何内部材料都在分隔线的边界内显示。此外,对齐属性控制材料出现的位置。在垂直模式下支持“top”、”center “和“bottom”,而“left”、”center “和“right “则是水平布局的对齐选择。

语法:

<p>....</p>

<p-divider align="...">
    ...
</p-divider>

<p>...</p>

Angular PrimeNG Divider内容属性:

  • align: 它用于设置内容的对齐方式。它是字符串数据类型,默认值为空。

创建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 Divider Content使用left和center对齐_。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Divider Content</h5>
<p>
    Angular PrimeNG is a framework used
    with angular to create components with
    great styling and this framework is
    very easy to use and is used to make
    responsive websites.
</p>
  
<p-divider align="left">
    <i class="pi pi-user mr-1"></i>
    <b>GeeksforGeeks</b>
</p-divider>
  
<p>
    Angular PrimeNG is a framework used
    with angular to create components with
    great styling and this framework is
    very easy to use and is used to make
    responsive websites.
</p>
  
<p-divider align="center">
    <span class="p-tag">GeeksforGeeks</span>
</p-divider>
  
<p>
    Angular PrimeNG is a framework used
    with angular to create components with
    great styling and this framework is
    very easy to use and is used to make
    responsive websites.
</p>
  • app.component.ts:
import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {}
  • app.module.ts:
import { NgModule } from "@angular/core";
import { BrowserModule } 
    from "@angular/platform-browser";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DividerModule } from "primeng/divider";
import { ButtonModule } from "primeng/button";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        DividerModule,
        ButtonModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {}

输出:

Angular PrimeNG分割器内容

示例2:这是另一个示例代码,说明了Angular PrimeNG Divider Content使用left和center对齐。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Divider Content</h5>
<p>
    Angular PrimeNG is a framework used
    with angular to create components with
    great styling and this framework is
    very easy to use and is used to make
    responsive websites.
</p>
  
<p-divider align="right">
    <p-button
        label="Logout"
        icon="pi pi-power-off"
        styleClass="p-button-outlined">
    </p-button>
</p-divider>
  
<p>
    Angular PrimeNG is a framework used
    with angular to create components with
    great styling and this framework is
    very easy to use and is used to make
    responsive websites.
</p>
  
<p-divider align="center">
    <span class="p-tag">GeeksforGeeks</span>
</p-divider>
  
<p>
    Angular PrimeNG is a framework used
    with angular to create components with
    great styling and this framework is
    very easy to use and is used to make
    responsive websites.
</p>
  • app.component.ts:
import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {}
  • app.module.ts:
import { NgModule } from "@angular/core";
import { BrowserModule } 
    from "@angular/platform-browser";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DividerModule } from "primeng/divider";
import { ButtonModule } from "primeng/button";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        DividerModule,
        ButtonModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule {}

输出:

Angular PrimeNG分割器内容

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程