Open In App

Angular PrimeNG Form Editor Properties Component

Last Updated : 09 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will see how to use the Form Editor Properties Component in Angular PrimeNG.

The Form Editor is a Quill-based rich text editor component.

Angular PrimeNG Form Editor Component properties:

  • style: It is used to style the container inline. It is of string data type, the default value is null.
  • styleClass: It is used to set the style class of the element. It is of string data type, the default value is null.
  • placeholder: It is the text to display when the editor is empty. It is of string data type, the default value is null.
  • readonly: It is used to check if the editor should be constructed in read-only mode. It is of a boolean data type, and the default value is false.
  • formats: It is the list of acceptable formats for display. It is of string data type, the default value is null.
  • modules: It is used to set the editor module. It is of any data type, the default value is null.
  • debug: It is a debug shortcut. The static method debug will have an impact on all Quill editor instances on the page. By default, only error and warning messages are activated. It is of string data type, the default value is null.
  • bounds: The editor’s p elements (such as tooltips, etc.) should be included within the DOM Element or a CSS selection for a DOM Element. Right now, it just takes into account left and right limits.
  • scrollingContainer: It is used if the default ql-editor has been replaced with a custom CSS version, the DOM Element or a CSS selector for a DOM Element must specify which container has the scrollbars (for example, overflow-y: auto). When Quill is configured to automatically increase its height and another ancestor container is in charge of the scrolling, it is necessary to fix scroll jumping bugs.

Creating Angular application & module installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

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

Project Structure: It will look like the following:

 

  • Steps to run the application: To run the above file run the below command:
ng serve --save

Example 1: Below is the example that illustrates the use of the Angular PrimeNG Form Editor Properties Component.

  • app.component.html:

HTML




<h2 style="color: green">
    GeeksforGeeks
</h2>
  
<h5>
    Angular PrimeNG Form
    Editor Properties.
</h5>
  
<p-editor [style]="{ height: '350px' }">
    <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-clean"
                    aria-label="clean">
            </button>
            <button type="button"
                    class="ql-image"
                    aria-label="Image">
            </button>
            <button type="button"
                    class="ql-link"
                    aria-label="Link">
            </button>
        </span>
    </ng-template>
</p-editor>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent { }


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { EditorModule } from 'primeng/editor';
import { AppComponent } from './app.component';
import { InputMaskModule } from 'primeng/inputmask';
  
@NgModule({
    imports: [
        EditorModule,
        BrowserModule,
        BrowserAnimationsModule,
        InputMaskModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule { }


Output:

 

Example 2: Below is another example that illustrates the use of the Angular PrimeNG Form Editor Properties Component.

  • app.component.html:

HTML




<h2 style="color: green">
  GeeksforGeeks
</h2>
<h5>Angular PrimeNG Form Editor Properties</h5>
<p-editor [(ngModel)]="gfg"
          [style]="{ height: '120px' }">
</p-editor>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent {
    gfg: string =
        `<div>GeeksforGeeks!</div>
         <div>It is a Computer Science Portal</div>`;
}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { EditorModule } from 'primeng/editor';
import { AppComponent } from './app.component';
import { InputMaskModule } from 'primeng/inputmask';
  
@NgModule({
    imports: [
        EditorModule,
        BrowserModule,
        BrowserAnimationsModule,
        InputMaskModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule { }


Output:

 

Reference: https://primefaces.org/primeng/editor



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads