首页 > 解决方案 > 无法在角度电子邮件编辑器中读取未定义的属性“值”

问题描述

当我尝试加载数据时出现此错误

HTML

<button (click)="exportHtml()">Export</button>
<button (click)="loadDesign()">Import</button>
<email-editor></email-editor>

打字稿

  export class EmailComponent implements OnInit {

  data: any
  @ViewChild(EmailEditorComponent) private emailEditor: EmailEditorComponent;
  constructor(private emailService: EmailService) { }

  exportHtml() {
    this.emailEditor.exportHtml((data: { chunks: any, design: any, html: any }) => {
      this.data = data
    })
  }

  loadDesign() {
   console.log(this.data)
   this.emailEditor.loadDesign(this.data)
  }
}

角度电子邮件编辑器

标签: angular

解决方案


我找到了解决方案。我犯了一个错误,我传递了整个对象 contains和htmlproperties 。实际上该方法需要属性。jsondesigndesign

loadDesign() {
  console.log(this.data)
  this.emailEditor.loadDesign(this.data.design)
} 

推荐阅读