I'm trying to host independent angular elements that I can drop into a non-angular webpage. It's working great when I have just one.. but when I load two or more on the same page I get this error:
Uncaught Error: Zone already loaded.
I'm using a build script to concatenate my dist files into one js file.. and then dropping that into my project
const fs = require('fs-extra') const concat = require('concat') const files = [ './dist/elementsApp/runtime.js', './dist/elementsApp/polyfills.js', './dist/elementsApp/scripts.js', './dist/elementsApp/main.js', ] fs.ensureDir('elements') .then(() => { console.log('success!') concat(files, 'elements/include-me-somewhere-else.js') }) .catch(err => { console.error(err) })
I can only have one of these js files on one page. I understand angular 7 will make this whole process easier but I'm wondering how I can accomplish this right now.
I've also tried wrapping my exported js file in a self-executing function to try and limit scope.. Doesn't fix anything unfortunately.
Any ideas?
People seem confused about what angular elements are. For clarification you can watch this video https://www.youtube.com/watch?v=4u9_kdkvTsc. the last few mins in particular show an angular element being exported and included on a non angular page. I'm trying to include multiple elements on the same page.
Web components are a set of browser APIs that enable developers to create custom and reusable HTML tags that can be used in web apps just like standard HTML tags. Since Web components are built on top of standards, they can work across all modern web browsers.
A Web Component, on the other hand, can be used anywhere. We can use it in React, Vue, Angular, or any other web application. Angular or any other frontend framework is the way to go when your components need to handle a lot of data that needs to be passed down to child components.
I think you should not use 2 angular on one site.
Solutions can be:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With