Vladyn
Vladyn

Reputation: 583

Load Angular in a framework or attach it to a DOM element

I have a situation where I have to embed a bundled Angular application and initialize it in another framework. In my case, it is Aurelia, but the question is more general, and a valid answer could be just attaching and starting the Angular app. So, I have literally pasted this in my template:

<template>
  <h1>${message}</h1>
  <p>${value}</p>
  <app-root></app-root>
  <script src="../../lib/third-parties/my-app/polyfills.js" type="module"></script>
  <script src="../../lib/third-parties/my-app/scripts.js" defer></script>
  <script src="../../lib/third-parties/my-app/main.js" type="module"></script>
</template>

When I inspect the DOM, I see the scripts and the app root element, but the app isn't starting. I do nothing in my controller of this view. So basically I'm looking for a snipped where I can launch a bundled app and attach it to the dom element. Also, I spend some time (and please skip for recommendation) playing around with Angular Element and exporting them to custom elements. Although the concept is super elegant, it is edgy and fragile. I never managed to mimic my whole app behavior with them.

Upvotes: 0

Views: 22

Answers (0)

Related Questions