Angular PrimeNG简单卡

Angular PrimeNG简单卡

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

卡片组件用于显示灵活和可扩展的内容容器。

语法:

<p-card header='....' subheader='...'>
    <p>...</p>
</p-card>

Angular PrimeNG卡的简单卡片属性:

  • 头部。它指定了卡片的标题。它是字符串数据类型,默认值为空。
  • 副标题。它指定了卡片的副标题。它是字符串数据类型,默认值为空。

创建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 Card Simple Card.的使用。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Card Simple Card</h5>
<p-card header=
    "Angular PrimeNG Card component" 
     [style]="{'width': '35rem'}">
     <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-card>
  • app.component.ts:
import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: []
})
  
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 { ButtonModule } from 'primeng/button';
import { CardModule, } from 'primeng/card';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        CardModule,
        ButtonModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule {}

输出:

Angular PrimeNG简单卡

示例2:这是另一个示例代码,说明了Angular PrimeNG Card Simple Card使用subheader

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Card Simple Card</h5>
<p-card header='GeeksforGeeks' 
    subheader="Angular PrimeNG Card Simple Card" 
    [style]="{'width': '35rem'}">
    <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-card>
  • app.component.ts:
import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: []
})
  
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 { ButtonModule } from 'primeng/button';
import { CardModule, } from 'primeng/card';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        CardModule,
        ButtonModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule {}

输出:

Angular PrimeNG简单卡

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程