Angular PrimeNG Accordion 默认

Angular PrimeNG Accordion 默认

Angular PrimeNG是一个开源框架,拥有丰富的原生Angular UI组件,可用于出色的造型,该框架可用于制作响应式网站,非常方便。在这篇文章中,我们将看到如何在Angular PrimeNG中使用Accordion Default,同时了解代码中会用到的属性及其语法。

Accordion组件被用来在标签中呈现自定义内容的特定部分。该元素可以包含一个以上的p-accordionTab元素。

语法:

<p-accordion>
 <p-accordionTab 
  header="..." 
  [selected]="true">
    ....
 </p-accordionTab>
 .......
</p-accordion>

Angular PrimeNG Accordion 默认属性:

  • header。它指定了标签的标题。它是字符串数据类型,默认值为空。
  • selected。它定义了标签是否被激活。它是布尔数据类型,默认值是false。

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

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

ng new appname

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

cd appname

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

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

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

Angular PrimeNG Accordion 默认

  • 运行该应用程序的步骤。运行下面的命令,看看输出情况。
ng serve --open

例子1:下面的例子说明了Angular PrimeNG Accordion Default的使用。

<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Accordion Default</h5>
<p-accordion>
    <p-accordionTab header="Angular PrimeNG" 
                    [selected]="true">
        <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-accordionTab>
    <p-accordionTab header="Angular PrimeNG">
        <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-accordionTab>
    <p-accordionTab header="Angular PrimeNG">
        <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-accordionTab>
</p-accordion>
import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
})
export class AppComponent { }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { AccordionModule } from 'primeng/accordion';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AccordionModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
export class AppModule { }

输出:

Angular PrimeNG Accordion 默认

例子2:下面是另一个例子,说明了Angular PrimeNG Accordion Default的使用。

<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Accordion Default</h5>
<p-accordion>
    <p-accordionTab header="Angular PrimeNG">
        <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-accordionTab>
    <p-accordionTab header="Angular PrimeNG">
        <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-accordionTab>
    <p-accordionTab header="Angular PrimeNG" 
                    [selected]="true">
        <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-accordionTab>
</p-accordion>
import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
})
export class AppComponent { }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { AccordionModule } from 'primeng/accordion';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AccordionModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
export class AppModule { }

输出:

Angular PrimeNG Accordion 默认

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程