Custom Element in Angular 17

Discussão em 'Angular' iniciado por user23353796, Outubro 25, 2024.

  1. user23353796

    user23353796 Guest

    since I updated Angular to version 17 I can't create web components.. I used to do it in app.module, where are they created now? I tried in app.component as the guide says but it doesn't seem to work.. Can someone help me please??

    I tried in app.component as the guide says but it doesn't seem to work..

    @Component({
    standalone: true,
    selector: 'app-root',
    template: `
    <input #input value="Message" />
    <button type="button" (click)="popup.showAsElement(input.value)">Show as element</button>
    `,
    providers: [PopupService],
    imports: [PopupComponent],
    })
    export class AppComponent {
    constructor(
    injector: Injector,
    public popup: PopupService,
    ) {
    // Convert `PopupComponent` to a custom element.
    const PopupElement = createCustomElement(PopupComponent, {injector});
    // Register the custom element with the browser.
    customElements.define('popup-element', PopupElement);
    }
    }

    Continue reading...

Compartilhe esta Página