Angular PrimeNG ProgressSpinner组件
Angular PrimeNG是一个开源框架,它拥有丰富的原生Angular UI组件,这些组件被用来做很好的造型,这个框架被用来制作响应式网站,非常容易。在这篇文章中,我们将了解如何在Angular PrimeNG中使用ProgressSpinner组件。我们还将学习属性、造型以及代码中使用的语法。
ProgressSpinner:该组件用于制作一个说明进程状态的旋转器。
属性:
- strokeWidth: 它指定了圆圈笔触的宽度。它接受一个字符串数据类型作为输入,默认值为2。
- fill:它指定了圆的背景颜色。它是字符串数据类型,默认值为空。
- animationDuration。指定旋转动画的持续时间。它是字符串数据类型,默认值是2s。
样式:
- p-progress-spinner:它是容器元素。
- p-progress-circle:它是SVG的造型元素。
- p-progress-path。它是圆形的造型元素。
创建Angular应用程序和模块安装。
第1步:使用以下命令创建一个Angular应用程序。
ng new appname
第2步:在创建你的项目文件夹即应用程序名称后,使用以下命令移动到它。
cd appname
第3步在你给定的目录中安装PrimeNG。
npm install primeng --save
npm install primeicons --save
项目结构:完成安装后,它将看起来像下面这样。
例子1:这是一个基本的例子,说明如何使用ProgressSpinner组件。
<h2>GeeksforGeeks</h2>
<h5>PrimeNg ProgressSpinner Component</h5>
<p-progressSpinner></p-progressSpinner>
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { ProgressSpinnerModule }
from 'primeng/progressspinner';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
ProgressSpinnerModule,
FormsModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html'
})
export class AppComponent {}
输出:
例子2:在这个例子中,我们将在progressSpinner组件中使用strokeWidth、fill和animationduration属性。
<h2>GeeksforGeeks</h2>
<h5>PrimeNG ProgressSpinner Component</h5>
<p-progressSpinner strokeWidth="5" fill="#03fc24"
animationDuration="1s"></p-progressSpinner>
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { ProgressSpinnerModule } from 'primeng/progressspinner';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
ProgressSpinnerModule,
FormsModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html'
})
export class AppComponent {}
输出: