Angular integration

Embed the hosted MailLayers editor in Angular

Use the lightweight Angular SDK to mount the hosted MailLayers editor in an iframe with a native standalone component, typed inputs and outputs, and lifecycle cleanup.

Published on npm

Version 0.1.0 · Install from npm or review the source on GitHub.

npm install @maillayers/angular-email-editor
Angular standalone component
import { Component } from "@angular/core";
import { MailLayersEmailEditorComponent } from "@maillayers/angular-email-editor";

@Component({
  standalone: true,
  imports: [MailLayersEmailEditorComponent],
  template: `
    <maillayers-email-editor
      [apiKey]="apiKey"
      [embedToken]="embedToken"
      initialHtml="<h1>Welcome</h1>"
      (change)="onChange($event)"
      (save)="onSave($event)"
      (ready)="onReady()"
      (authError)="onAuthError($event)"
    />
  `,
})
export class EditorPage {
  apiKey = "your-browser-sdk-key";
  embedToken = "server-issued-token";

  onSave(html: string) {
    this.persistHtml(html);
  }
}

Production integration

Content, assets, security, and lifecycle

A useful embedded email editor is more than a mounted component. Plan the persistence and trust boundaries before connecting it to customer data.

Editor data methods

Use getHtml() for a sendable snapshot and getJson() for structured editor state. Call reload() only when staged content or configuration should start a new iframe handshake; use ready, load, change, save, and status callbacks for normal updates.

Assets

Implement upload, list, and delete handlers against storage owned by your application. Validate file type and size on the server, authorize each tenant-scoped object, return HTTPS URLs, and treat delete as an authenticated operation.

API keys and allowed domains

Use a browser SDK key only from an exact configured origin. Keep privileged secrets on your server, issue scoped embed tokens after authenticating the user, and do not treat iframe messages as trusted until origin and payload validation pass.

Multiple instances

Give each mounted editor stable state and separate callbacks. Avoid reusing one imperative ref across instances, and unmount inactive editors when tabs or routes no longer need them so listeners and iframe resources are released.

Performance

Reserve editor height to prevent layout shift, defer mounting until the authoring UI is needed, and show a stable loading fallback. Avoid remounting the iframe for ordinary form-state changes; prefer events and staged reloads.

Troubleshooting

If the editor does not become ready, verify the allowed origin, browser key, embed-token lifetime, editor URL, and Content Security Policy. For missing saves, inspect callback errors and confirm the host persistence request succeeds independently of the iframe.

Integration

Angular binds to a hosted iframe bridge

  1. 01

    Import MailLayersEmailEditorComponent directly in a standalone component, or import MailLayersEmailEditorModule in an NgModule application.

  2. 02

    Bind apiKey, embedToken, and initialHtml inputs, then handle change, save, ready, and authError outputs in the host component.

  3. 03

    Use ViewChild for reload when staged initial content or configuration should begin a new handshake. Angular destroys the iframe bridge during ngOnDestroy.

Relevant capabilities

What this integration actually supports

Standalone and NgModule
The Angular package exposes both modern standalone use and a compatibility module for Angular 18–20.
Full asset callbacks
Upload, list, and delete handlers connect the editor to your storage boundary.
Typed outputs
Change, save, ready, status, load, and sanitized authError events use Angular output bindings.

Product boundary: MailLayers is the hosted editing surface, not an authentication provider, asset store, approval engine, ESP, or email delivery service. Imports are SSR-safe, but the editor mounts only in a browser with a real host element.

Related integration guides

Engineering articles

Read implementation notes about editor security, persistence, asset workflows, and framework-specific patterns.

Browse the MailLayers blog

FAQ

Questions specific to this integration

Is this an in-process editor?

No. The Angular SDK is a lightweight iframe wrapper that communicates with the hosted MailLayers editor through a secured postMessage protocol.

Which Angular versions are supported?

Angular 18, 19, and 20. Peer dependencies require @angular/core and @angular/common >=18.0.0 <21.0.0.

Can it render during SSR?

Imports are SSR-safe, but the editor mounts only in a browser with a real host element.

Continue with the verified integration guide

Review licensing, allowed domains, events, assets, SSR boundaries, and troubleshooting before production use.