I have added Quilljs editor on my page. I am trying to fetch the valve of the content.
I am following a video on YouTube called "Using Quill JS Text Editor With Angular 7". I have done everything as shown but I am getting this error:
ERROR Error: Uncaught (in promise): Error: Template parse errors:
No provider for NgControl ("
<form [FormGroup="editorForm" (ngSubmit)="OnSubmit()"]>
<div class="form-group">
[ERROR ->]
<quill-editor formControlName="editor"></quill-editor>
</div>
<ion-button type="submit">
Submit</ion"): ng:///HomePageModule/HomePage.html@11:2
Error: Template parse errors:
No provider for NgControl ("
<form [formGroup]="editorForm" (ngSubmit)="OnSubmit()">
<div class="form-group">
[ERROR ->]
<quill-editor formControlName="editor"></quill-editor>
</div>
<ion-button type="submit">
Submit</ion"): ng:///HomePageModule/HomePage.html@11:2
at syntaxError (compiler.js:2420)
My home.html
code:
<ion-content class="ion-padding">
<form [formGroup]="editorForm" (ngSubmit)="OnSubmit()">
<div class="form-group">
<quill-editor formControlName="editor"></quill-editor>
</div>
<ion-button type="submit">Submit</ion-button>
</form>
The world is your oyster.
<p>If you get lost, the <a target="_blank" rel="noopener" href="https://ionicframework.com/docs/">docs</a> will be your guide.</p>
</ion-content>
home.ts
code:
import { Component } from '@angular/core';
import { QuillModule } from 'ngx-quill';
import {FormGroup, FormControl} from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
editorForm: FormGroup;
ngOnInit(){
// console.log(quill.container.innerHTML);
this.editorForm = new FormGroup({
'editor': new FormControl(null)
})
}
OnSubmit(){
console.log(this.editorForm.get('editor').value);
}
}
I have imported FormsModule, ReactiveFormsModule in app.module.ts
and home.module.ts
but nothing is working.
How can I resolve this error and get the value of Quill editor?
After small code correction[brackets], now it is saying:
Can't bind to 'formGroup' since it isn't a known property of 'form'.
Please add ReactiveFormsModule
to imports
section of HomeModule
.
It is the first step of reactive forms guide.