ck编辑器反应形式angular 6不起作用

时间:2018-08-20 06:26:45

标签: angular

角6反应形式的

ck编辑器不起作用。

出错
  

没有名称为'description'的表单控件的值访问器

我已经在我的app.module.ts和当前页面中导入了ck编辑器。但是我仍然遇到相同的错误。下面是我的cms-add html页面:

  <form [formGroup]="addCMSForm" (ngSubmit)="onSubmit()">
            <div class="box-body">
              <div class="col-xs-12">
                <div class="form-group padding">
                  <label for="inputEmail3" class="col-sm-2 control-label">Description</label>
                  <div class="col-sm-10">
                    <ckeditor formControlName="description" #description skin="moono-lisa" language="en" [fullPage]="false"></ckeditor>
                  </div>
                </div>
              </div>
              <div class="clearfix"></div>

              </div>
              <div class="col-xs-12">
                <div class="form-group padding">
                  <button [disabled]="addCMSForm.invalid" class="btn btn-primary">Submit</button>
                  <a [routerLink]="['/cms-list']" class="btn btn-danger" role="button">Back</a>
                </div>
              </div>
            </div>
          </form>

我已经创建了打字稿页面,这是我的cms-add.ts页面。您能以反应形式解决我的问题.ck编辑器吗?

import { Component, Inject, OnInit, OnDestroy } from '@angular/core';
import { Http } from '@angular/http';
import { RouterModule, ActivatedRoute, Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators, FormControl } from "@angular/forms";
import { CKEditorModule } from 'ngx-ckeditor';

@Component({
  selector: 'cms-add',
  templateUrl: './cms-add.component.html'

})
export class CMSAddComponent implements OnInit, OnDestroy {
  title = 'Add CMS';
  addCMSForm: FormGroup;

  constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router) {
    this.createForm();
  }

  createForm() {
    this.addCMSForm = this.formBuilder.group({               
      description: ['']   
    });
  }

将错误显示为名称为表单控件的无值访问器: '说明'

  

ERROR错误:名称为表单控件的无值访问器:   '描述'           在_throwError(vendor.js:53593)           在setUpControl(vendor.js:53503)           在FormGroupDirective.push ../ node_modules/@angular/forms/fesm5/forms.js.FormGroupDirective.addControl   (vendor.js:56315)           在FormControlName.push ../ node_modules/@angular/forms/fesm5/forms.js.FormControlName._setUpControl   (vendor.js:56820)           在FormControlName.push ../ node_modules/@angular/forms/fesm5/forms.js.FormControlName.ngOnChanges   (vendor.js:56770)

请帮助解决此错误。

1 个答案:

答案 0 :(得分:0)

我看到您在组件中导入了CKEditorModule

ngx-ckeditor文档:https://www.npmjs.com/package/ngx-ckeditor中,应在模块中导入CKEditorModule模块,然后在组件中使用它。

希望这对您有所帮助。