Angular4+ 没有表单控件的值访问器
Angular4+ No value accessor for form control
我在使用 angular 表单值访问器时遇到了很大的麻烦。
错误如下:"No value accessor for form control with name: 'textTitle'" 来自 SectionComponent.ngfactory.js
我正在使用一个名为 ContentEditable 的 angular 库,它实现了 ControlValueAccessor 以将文本设置为可编辑并将其 link 设置为表单。
这是我的反应形式:
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>
我不明白我做错了什么。感谢您的帮助。
formControlName 必须用于 input html tags
他妈的!
这是因为我使用了 contentEditable 属性 而不是 contenteditable...
我喜欢这种错误描述...
我在使用 angular 表单值访问器时遇到了很大的麻烦。 错误如下:"No value accessor for form control with name: 'textTitle'" 来自 SectionComponent.ngfactory.js 我正在使用一个名为 ContentEditable 的 angular 库,它实现了 ControlValueAccessor 以将文本设置为可编辑并将其 link 设置为表单。
这是我的反应形式:
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>
我不明白我做错了什么。感谢您的帮助。
formControlName 必须用于 input html tags
他妈的!
这是因为我使用了 contentEditable 属性 而不是 contenteditable...
我喜欢这种错误描述...