Open In App

Angular PrimeNG Form Editor Default Component

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 show us how to use the Form Editor Default Component in Angular PrimeNG. We will also learn about the various properties and syntaxes used in the code example.

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

Angular PrimeNG Form Editor Default Component properties:

  • style: It is used to style the container inline.

 

Syntax:

<p-editor 
    [(ngModel)]="..." 
    [style]="{...}">
</p-editor>

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.

 

To run the above file run the below command:

ng serve --save

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

  • app.component.html:

HTML




<h2 style="color: green;">
    GeeksforGeeks
</h2>
  
<h5>Angular PrimeNG Form Editor Default Component</h5>
  
<p-editor [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 { }


  • 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 the example that illustrates the use of Angular PrimeNG Form Editor Default Component using [(ngModel)].

  • app.component.html:

HTML




<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Form Editor Default Component</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>
        <div><br></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



Last Updated : 17 Oct, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads