1

I have a shell application in Angular that currently renders applications in web component mode, using ax-lazy-element (Angular Extensions Elements). All communication between the parent shell application and the webcomponent application is done via Input and Output events to the application.

AS-IS

Code Application WebComponent

import { Injector } from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { AppComponent } from './app.component';

const element = createCustomElement(AppComponent, { injector });
customElements.define('my-microfrontend', element);

Dynamically load the web component in app shell

<my-microfrontend
  *axLazyElement="['https://cdn.example.com/microfrontend.js']"
  [inputProp]="data"
  (outputEvent)="handleEvent($event)">
</my-microfrontend>

Traffic Input and Output Data

import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `<div>{{ inputProp }}</div>`,
})
export class AppComponent {
  @Input() inputProp: string;
  @Output() outputEvent = new EventEmitter<string>();

  someMethod() {
    this.outputEvent.emit('some data');
  }
}

I also want to allow and load Angular applications with SSR and SSG within my shell application. In this case, I have doubts about what would be the best way to integrate these applications within my shell app and communicate and receive events in this model.

enter image description here

I thought about using Iframes with PostMessage, but that is very ugly... Can I use other ways to meet this scenario?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.