Angular PrimeNG Focus Trap编辑器
Angular PrimeNG是一个开源框架,拥有丰富的原生Angular UI组件,可以用来做很好的造型,这个框架用来制作响应式网站非常方便。本文将告诉我们如何在Angular PrimeNG中使用Focus Trap Editor。我们还将学习各种属性和它们在代码示例中的语法。
Angular PrimeNG Focus Trap是用来在我们用tab键进行tab时保持对某些DOM元素的关注。
语法:
<p-editor [style]="{....}">
<ng-template pTemplate="header">
<span class="ql-formats">
<button type="button"
class="..."
aria-label="...">
</button>
</span>
</ng-template>
</p-editor>
Angular PrimeNG Focus Trap Editor属性:
- style。它用于给编辑器提供自定义的样式。
创建Angular应用程序和模块安装:
第1步:使用以下命令创建一个Angular应用程序。
ng new appname
第2步:创建你的项目文件夹即appname后,使用以下命令移动到它。
cd appname
第3步:在你给定的目录中安装PrimeNG。
npm install primeng --save
npm install primeicons --save
项目结构:它将看起来像如下。
例子1:下面的例子说明了Angular PrimeNG Focus Trap Editor使用自定义按钮选项的用法。
<div pFocusTrap class="card">
<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Focus Trap Editor</h5>
<p-editor [style]="{ height: '200px' }">
<ng-template pTemplate="header">
<span class="ql-formats">
<button type="button"
class="ql-bold"
aria-label="Bold">
</button>
<button type="button"
class="ql-italic"
aria-label="Italic">
</button>
<button
type="button"
class="ql-underline"
aria-label="Underline">
</button>
<button type="button"
class="ql-strike"
aria-label="strike">
</button>
<button
type="button"
class="ql-blockquote"
aria-label="blockquote">
</button>
</span>
</ng-template>
</p-editor>
</div>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
})
export class AppComponent {}
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from
'@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { EditorModule } from 'primeng/editor';
@NgModule({
imports: [BrowserAnimationsModule, EditorModule],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
输出:
例子2:下面的例子说明了Angular PrimeNG Focus Trap Editor使用默认的编辑器选项的用法。
<div pFocusTrap class="card">
<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Focus Trap Editor</h5>
<p-editor [style]="{ height: '200px' }"></p-editor>
</div>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
})
export class AppComponent {}
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from
'@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { EditorModule } from 'primeng/editor';
@NgModule({
imports: [BrowserAnimationsModule, EditorModule],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
输出: