【发布时间】:2020-05-23 14:10:43
【问题描述】:
我在我的页面上添加了 Quilljs 编辑器。我正在尝试获取内容的阀门。
我正在关注 YouTube 上的一个名为“Using Quill JS Text Editor With Angular 7”的视频。如图所示,我已完成所有操作,但出现此错误:
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)
我的home.html 代码:
<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代码:
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);
}
}
我在 app.module.ts 和 home.module.ts 中导入了 FormsModule、ReactiveFormsModule,但没有任何效果。
如何解决此错误并获取 Quill 编辑器的值?
编辑 1
经过小代码更正[括号],现在是说:
无法绑定到“formGroup”,因为它不是“form”的已知属性。
【问题讨论】:
-
我已经更正了,现在是
Can't bind to 'formGroup' since it isn't a known property of 'form'. -
您好 user2828442。快速提醒一下,引号块(使用 > 设备)仅用于引号,而不是一般的荧光笔。
标签: angular ionic-framework ionic4 ngx-quill