ngModel not binding to tinymce in angular 5

Viewed 1359

I am integrated tinymce in angular 5 project, it working fine but data binding is not working. how can i achieve data binding with tinymce in angular5 project. I am trying binding 'tinymce' text editor with 'ngmodel'. i am not able to do. can you please help me any one. i have tried bellow code.

html

    <editor [(ngModel)]="dataModel"></editor>

script

import { EditorModule } from '@tinymce/tinymce-angular';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    EditorModule // <- Important part
  ],
  providers: [],
  bootstrap: [AppComponent]
})
2 Answers

Make sure to import FormsModule in app.module.ts.

import { EditorModule } from '@tinymce/tinymce-angular';
import { FormsModule } from '@angular/forms';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    EditorModule,
    FormsModule // <--- here
  ],
  providers: [],
  bootstrap: [AppComponent]
})

data binding should work fine with already mentioned up, but here is again.

<editor [(ngModel)]="textdata" apiKey="your api key" [init]="{plugins: 'link'}"></editor>

If you print it in html like {{textdata}} you will get all with tags.

Related