Ionic 如何将变更事件纳入tinymce?

aor9mmx1  于 2022-12-08  发布在  Ionic
关注(0)|答案(2)|浏览(172)

I am trying to use angular2-tinymce library in my project. I have successfully integrated tinymce in my module. But i could not trigger any callback for change event when any changes happened in the tinymce editor.

// in add-progress-note.module.ts file
@NgModule({
  declarations: [
    AddProgressNotePage,
  ],
  imports: [
    IonicPageModule.forChild(AddProgressNotePage),
    TinymceModule.withConfig({
      menubar: false,
      plugins: ['textcolor'],
      toolbar: 'forecolor',
      resize: false,
      statusbar: false
    })
  ]
})

// in add-progress-note.html file           
<ion-row class="note-editor" id="noteArea">
            <app-tinymce class="note-input-textarea" [(ngModel)]='noteText' (change)="onChangeNote()"></app-tinymce>
</ion-row>

// in add-progress-note.ts file
  onChangeNote(): void {
    console.log(this.noteText);
  }

My onChangeNote did not fire.
How to trigger a callback event for any change event in tinymce editor?

siv3szwd

siv3szwd1#

如果您使用的是ngModel,则可以轻松地使用ngModelChange来代替change

<app-tinymce class="note-input-textarea" [(ngModel)]='noteText' (ngModelChange)="onChangeNote()"></app-tinymce>
ou6hu8tu

ou6hu8tu2#

Ok, i use that and it's work, thanks Suraj Rao
html :

<editor [(ngModel)]="html" [init]="init" (ngModelChange)="removeColor($event)"></editor>

TS :

public removeColor(value) {
        this.html = value.replace(/color(.*?);/i, '');;
    }

相关问题