我在使用角度形式值访问器时遇到了很大麻烦。 错误如下:来自SectionComponent.ngfactory.js的“名称为'textTitle'的表单控件的无值访问器” 我正在使用一个名为ContentEditable的有角度的库,该库实现ControlValueAccessor来将文本设置为可编辑并将其链接到表单。
这是我的反应形式:
this.form = new FormGroup({
descriptionText : new FormControl(this.descriptionText),
textTitle: new FormControl(this.titleText),
buttonText : new FormControl(this.buttonText)
})
这是可编辑的内容之一:
<form [formGroup]="form">
<div class="descriptionSectionBlock title" [ngStyle]='{ }'
*ngIf="currentSection.titleText.textDisplayed" >
<div [ngStyle]='{ }'>
<h2 contentEditable="true" formControlName="textTitle"
(blur)="updateTextContent('title')"
[ngStyle]='{ }'>
{{titleText}}
</h2>
</div>
</div>
<div class="descriptionSectionBlock description" [ngStyle]='{ }'
*ngIf="currentSection.descriptionText.textDisplayed" >
<div [ngStyle]='{ }'>
<p contentEditable="true" formControlName="descriptionText"
(blur)="updateTextContent('description')"
[ngStyle]='{ }'>
{{descriptionText}}
</p>
</div>
</div>
<div [ngStyle]='{ }' class="descriptionSectionBlock button"
*ngIf="currentSection.CTAButtonDisplay">
<button contentEditable="true" formControlName="buttonText" (mouseover)="hover=true" (mouseleave)="hover=false"
(blur)="updateTextContent('button')"
[ngStyle]='{
}' mat-raised-button>
{{buttonText}}
</button>
</div>
</form>
我不明白我做错了什么。感谢您的帮助。
答案 0 :(得分:0)
formControlName必须用于输入 html标记
答案 1 :(得分:0)
Fuckinhell!
那是因为我使用了contentEditable属性,而不是contenteditable属性...
我喜欢这种错误描述...