Reputation: 113
Here's my code :
<div #editor class="editor"
style=" max-height: 200px;"
(input)="onChange()"
[(ngModel)]="blogData.description"
name="description"
contenteditable></div>
The Error that i am getting:
Error: No value accessor for form control with name: 'description'
How can i use [(ngModel)] as well as innerHTML property on div's contenteditable?
Upvotes: 2
Views: 516
Reputation: 3631
You need to write your own ControlValueAccessor
to work with contenteditable:
https://angular.io/api/forms/ControlValueAccessor
I already did it and released it as opensource package, feel free to use it: https://github.com/TinkoffCreditSystems/angular-contenteditable-accessor https://www.npmjs.com/package/@tinkoff/angular-contenteditable-accessor
It works with all modern browsers, including IE11.
Upvotes: 4