Angular

Frameworks

Angular

A drop-in for angular-email-editor, the <email-editor> component and EmailEditorComponent.

bash
npm install angular-email-craft
tsapp.component.ts
import { Component, ViewChild } from "@angular/core";
import { EmailEditorComponent } from "angular-email-craft";

@Component({
  standalone: true, imports: [EmailEditorComponent], template: `
    <button (click)="exportHtml()">Export</button>
    <email-editor [options]="options" (loaded)="editorLoaded()"></email-editor>
  `,
})
export class AppComponent {
  @ViewChild(EmailEditorComponent) private emailEditor!: EmailEditorComponent;
  options = { displayMode: "email" };

  editorLoaded() {
    console.log("Editor is ready");
  }
  exportHtml() {
    this.emailEditor.editor?.exportHtml((data) => console.log("exportHtml", data));
  }
}
Prefer standalone components (shown above). An EmailEditorModule is also exported for classic NgModule apps: imports: [EmailEditorModule].

Next: Methods & ref.

Inputs and outputs

Besides options, the component takes token (your pk_live_ key), displayMode, design (loaded once the editor is ready), mergeTags, locale, fonts, minHeight (default 500px) and onImageUpload. A top-level input wins over the same key inside options.

  • (loaded) fires when the editor frame has loaded, before it is ready. Calls made then are queued.
  • (ready) fires when the editor has finished loading, with the editor handle.
  • (updated) fires on every design change.
  • (error) gives { code, message } when the editor cannot run as set up, such as a wrong embedUrl or a token that is invalid or not allowed on this site.

Changing inputs after mount

A new token, displayMode, locale, fonts, embedUrl or runtimeUrl (and a few other mount-time inputs) restarts the editor, and the current design is carried over. An object literal that only gets a new identity does not restart it. A new mergeTags value is pushed to the running editor. Later changes to design, options and minHeight are ignored, so call loadDesign to show another design.

With Angular Universal, nothing is rendered on the server; the editor mounts in the browser after hydration.