Content is user-generated and unverified.
// ============================================================================= // iframe-map-host.directive.ts — Directive qui lie un <iframe> au manager // ============================================================================= // S'applique sur un élément <iframe> et gère automatiquement : // - l'enregistrement auprès de IframeManagerService // - l'attachement de l'élément DOM // - le désenregistrement à la destruction // ============================================================================= import { Directive, ElementRef, Input, OnInit, OnDestroy, inject, } from '@angular/core'; import { IframeManagerService } from './iframe-manager.service'; @Directive({ selector: 'iframe[mapIframeHost]', standalone: true, }) export class IframeMapHostDirective implements OnInit, OnDestroy { private readonly manager = inject(IframeManagerService); private readonly elRef = inject(ElementRef<HTMLIFrameElement>); /** Identifiant unique pour cette iframe */ @Input({ required: true, alias: 'mapIframeHost' }) iframeId!: string; /** Label lisible */ @Input() iframeLabel = ''; /** Métadonnées libres */ @Input() iframeMeta?: Record<string, unknown>; ngOnInit(): void { const el = this.elRef.nativeElement; // Enregistre l'instance this.manager.register({ id: this.iframeId, label: this.iframeLabel || this.iframeId, src: el.src, meta: this.iframeMeta, }); // Attache l'élément DOM this.manager.attachElement(this.iframeId, el); } ngOnDestroy(): void { this.manager.unregister(this.iframeId); } }
Content is user-generated and unverified.
    Angular iframe Map Host Directive Guide | Claude