Angular PrimeNG Form Password Password Meter组件

Angular PrimeNG Form Password Password Meter组件

Angular PrimeNG是一个开源框架,拥有丰富的原生Angular UI组件,可用于出色的造型,这个框架用于制作响应式网站,非常容易。在这篇文章中,我们将学习如何在Angular PrimeNG中使用Password密码表组件。

密码组件用于表示密码字段的强度指标。

语法:

<p-password
       placeholder="..."
    [feedback]="...">
</p-password>

Angular PrimeNG Form Password Password Meter 组件属性:

  • feedback。它用于显示强度指标或不显示。它是布尔数据类型,默认值为真。

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

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

ng new appname

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

cd appname

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

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

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

Angular PrimeNG Form Password Password Meter组件

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

ng serve --open

示例1:下面是说明使用,Angular PrimeNG Form Password Password Meter Component的示例代码。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>
    Angular PrimeNG Form Password 
    Password Meter Component
</h5>
  
<p-password 
    placeholder="Password">
</p-password>
  • 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 { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } 
   from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { PasswordModule } from 'primeng/password';
import { DividerModule } from 'primeng/divider';
  
@NgModule({
   imports: [
       BrowserModule,
       BrowserAnimationsModule,
       PasswordModule,
       DividerModule,
       FormsModule,
   ],
   declarations: [AppComponent],
   bootstrap: [AppComponent],
})
  
export class AppModule {}

输出:

Angular PrimeNG Form Password Password Meter组件

例子2:下面是另一个例子,说明了Angular PrimeNG Form Password Password Meter Component使用_feedback=”false”。

  • app.component.html:
<h1 style="color: green">GeeksforGeeks</h1>
<h5>
    Angular PrimeNG Form Password 
    Password Meter Component
</h5>
  
<p-password 
    placeholder="Password" 
    [feedback]="false">
</p-password>
  • 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 { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } 
   from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { PasswordModule } from 'primeng/password';
import { DividerModule } from 'primeng/divider';
  
@NgModule({
   imports: [
       BrowserModule,
       BrowserAnimationsModule,
       PasswordModule,
       DividerModule,
       FormsModule,
   ],
   declarations: [AppComponent],
   bootstrap: [AppComponent],
})
  
export class AppModule {}

输出:

Angular PrimeNG Form Password Password Meter组件

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程