无法在 TinyMCE 文本区显示我的 HTML 内容

Can't Display my HTML content on TinyMCE Text Area

我正在尝试使用 tinymce 而不是文本区域在我的应用程序模式上创建富文本编辑器。但是我的 HTML 代码无法在富文本的内容区域显示为文本。我正在使用 Angular 2.

如有任何帮助,我们将不胜感激

import { Component, AfterViewInit, OnDestroy, Input, Output, EventEmitter } from 'angular2/core';
import { RdComponent, RdLib } from '../../../../../node_modules/mulberry/core';

declare let tinymce: any;

@Component({
  selector: 'mail-template',
  template: `
            <textarea style="height:15em"><p>{{ content }}</p></textarea>            
            `
})
export class MailTemplatesComponent extends RdComponent {

  @Input("rd-model") model: string;

  @Output() onEditorKeyup = new EventEmitter<any>();
  public editor: any;

  ngAfterViewInit() {
    console.log(this.model);
    tinymce.init({
      selector: 'textarea',
      setup: editor => {
        this.editor = editor;
        editor.on('keyup', () => {
          const content = editor.getContent();
          this.onEditorKeyup.emit(content);
        })
      }
    });
  }

  ngOnDestroy() {
    tinymce.remove(this.editor);
  }

}
<div class="col-md-12">
   <rd-field [rd-text]="translate('Mail İçeriği')"></rd-field>
   <mail-template [(rd-model)]="data.MailContent" rd-height="25em"></mail-template>
</div>

我正在使用 angular2-froala-wyswiyg

this is the best i could find and easy to use (link below)

https://libraries.io/npm/angular2-froala-wyswiyg#usage

npm install angular-froala-wysiwyg --save
npm update froala-editor --save

package.json(文件) 安装模块后

  "dependencies": {
    .....
    "angular-froala-wysiwyg": "^2.7.2",
    ...
}

在您的模块中导入

import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
...

@NgModule({
   ...
   imports: [FroalaEditorModule.forRoot(), FroalaViewModule.forRoot() ... ],
   ...
})

angular-cli.json(文件) 如下所示更改样式和脚本

 "styles": [
    "styles.css",
    "../node_modules/froala-editor/css/froala_editor.pkgd.min.css",
    "../node_modules/froala-editor/css/froala_style.min.css",
    "../node_modules/font-awesome/css/font-awesome.css"
  ],
  "scripts": [
    "../node_modules/froala-editor/js/froala_editor.pkgd.min.js"
  ],

在你的组件模板中

 <textarea class="form-control" [froalaEditor] name="x" #x="ngModel [(ngModel)]="obj.name" required ></textarea>

编辑后显示为

<span [innerHTML]="obj.name"> </span> 

我找到了问题的最佳解决方案,我认为这对遇到相同问题的人会有帮助。

http://estynedwards.com/blog/2015/12/04/getting%20started%20with%20angular%202/