Search code examples
angularrichtextboxangular-formsform-control

Add formControlName in a div with contenteditable


I have a div with contenteditable="true" because i need a rich text component, and i tried a lot of libraries but nothing works, so i have my div editable but when i try to add the formControlName i got this error:

this is my HTML

<div formControlName="main_description" class="full" id="textBox" contenteditable="true"></div>

And this is the error

ERROR Error: No value accessor for form control with name: 'main_description'
at _throwError (forms.js:1734:1)
at setUpControl (forms.js:1508:1)
at FormGroupDirective.addControl (forms.js:5255:1)
at FormControlName._setUpControl (forms.js:5837:1)
at FormControlName.ngOnChanges (forms.js:5782:1)
at FormControlName.rememberChangeHistoryAndInvokeOnChangesHook (core.js:1520:1)
at callHook (core.js:2539:1)
at callHooks (core.js:2506:1)
at executeInitAndCheckHooks (core.js:2457:1)
at selectIndexInternal (core.js:8401:1)

Solution

  • I got the solution! I had to add an invisible input to assign the div data

    here is: https://github.com/Avalojandro/Angular-RichText-PureJS