angular-elements | hosting Angular Components as Custom Elements | Web Framework library
kandi X-RAY | angular-elements Summary
kandi X-RAY | angular-elements Summary
Sketching out hosting Angular Components as Custom Elements / Web Components.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular-elements
angular-elements Key Features
angular-elements Examples and Code Snippets
Community Discussions
Trending Discussions on angular-elements
QUESTION
I am currently trying out Angular Elements for creating web components. I have created a web component that works in an html page:
...ANSWER
Answered 2021-Apr-09 at 08:40Thanks to user14649759's tip, I was able to solve the problem! :)
Webpack 5 must be used. To achieve this, I have made the following changes:
QUESTION
Our Angular-Elements webcomponent should have the two methods openModal()
and closeModal()
that can be used as custom-element inside React, Vue or any other library to change the visibility state.
This simple javascript usage should be possible:
...ANSWER
Answered 2020-Dec-01 at 10:01@Input()
s are designed for properties, not functions. For your use case you can simply use a getter and return a function there.
As for the visible
state not changing: it does change (just check with console.log
after the change). However, the change is not detected by angular's change detection, since the call comes out of angulars context. You'd experience the same issue when using setTimeout
for example to change a value. To get around this, inject NgZone
into your component, and use this.zone.run
to have angular detect the changes.
QUESTION
I'm trying to create some custom elements with Angular Elements 8 and it works great when using simple objects as string/number on my @Input(). But when I wanted to start using arrays of objects IE EDGE/11 throws exceptions.
Procedure
Clone repo (code github repo) or do the following:
ng new "some name"
update browserlist to include IE11
ng generate component simple-list
Write code for component with inputs
Serve solution (without angular elements I know) and everything works.
Add angular elements (ng add @angular/elements)
Modify module to bootstrap component as custom element
Serve and load with EDGE, see console error
ANSWER
Answered 2019-Nov-27 at 16:16It is a defect in Angular/Elements. The polyfills arent't reliably calling the constructor when using document-register-elements.
To fix the problem switch to another polyfill for custom elements like @webcomponents/custom-elements
I created a fork of your project and fixed the issue.
QUESTION
Is there any way to use css selectors like :first-child, :not(:last-child) inside of the shadow dom?
The example is like this
CustomElement.html
...ANSWER
Answered 2020-Apr-28 at 19:19I found a workaround for this in JS way.
For each slot, we have a eventHandler called (slotchange). By using that we can get the DOM event for the slot whenever the slot changes. Like this (HTML)
QUESTION
Recently our team has decided to implement micro front end architecture in our legacy product. It has been developed using Asp.Net aspx pages along with javascript/jquery.
Last year we started using angular in our application for some of the views. To load angular we are placing the prod build files in .net project and we are loading the component in aspx master page.
We are planning to migrate our rest pending older views to angular using micro front end architecture.
So I did a small poc for the same and was able to achieve the architecture to somewhere close to it.
I followed this url for implementation and ran it on port 4400.
And in my existing angular project i am loading this using customElements
...ANSWER
Answered 2020-Mar-02 at 15:20For those who might have requirement like this.
I did lot of research and went through lot of articles and came out with a solution.
So I created a separate application using Angular elements and generated single bundle using cmd;
QUESTION
I recently downloaded the Angular CLI
(@angular/cli 9.0.1). I then proceeded to create a new application so that I could create a new Angular Element, package it up, and use it in another application.
After following a few blogs, the final step of every blog I came across all talk about creating a single JS file from the generated files dropped under the dist/ folder. For example: https://blog.bitsrc.io/using-angular-elements-why-and-how-part-1-35f7fd4f0457
Then using the cat command, we are concatenating the runtime.js, polyfills.js, scripts.js, and main.js files from the dist/angular-app folder into a angularapp.js file inside the preview folder.
Running ng build angular-app --prod --output-hashing=none
instead seems to produce files named:
- main-es5.js
- main-es2015.js
- polyfills-es5.js
- polyfills-es2015.js
- runtime-es5.js
- runtime-es2015.js
I scoured every single file that had the terms es5 and es2015 and changed it to es6, but it still produced the same es5 and es2015 file names. What am I doing wrong here?
...ANSWER
Answered 2020-Feb-12 at 15:57They are the same thing.
6th Edition - ECMAScript 2015
- 6th Edition ECMAScript -> ES6
- ECMAScript 2015 -> ES2015
Different names for the same thing. Angular has simply chosen to call it es2015.
QUESTION
I have a vector a
and need to perform a summation over two indices, something as
ANSWER
Answered 2020-Jan-12 at 16:29If I understand it correctly you want to do the following:
QUESTION
I have been trying all day to get an Angular elements component working, as I was considering using them in an upcoming project.
I have followed a number of tutorials (all very similar), and just cannot get them working. One of the tutorials is this one.
I have the following package.json for the Elements project
...ANSWER
Answered 2019-Aug-20 at 08:34I was able to reproduce your error. The problem comes from build-script.js
. You will have to modify it and make sure it's compiling only es2015.js
files instead of es5.js
. ES5 has some trouble working with native Custom Elements, therefore you will have to use ES2015.
So it will look something like this:
QUESTION
I need to create an Angular app with different microservices. There doesn't seem to be any clear tutorials on how to actually turn a component into a microservice. I tried this tutorial but it doesn't explain the packaging process. Is packaging a component into a microservice the same as packaging a library? Are they imported into a project the same way?
What is the best way to prepare a component so it can be consumed as a microservice?
...ANSWER
Answered 2019-Jul-18 at 15:07First of all, it is wrong to use 'microservices' term here. 'Micro frontend' is the one you should be using.
One possible solution would be to use Angular Elements / Web Components - the tutorial you linked mentions that.
Once you properly build Angular Element - useful read, you will be provided with one .js
file (you will have to merge few files into one file). After that is done, you import this .js
file in your main application (wrapper application) and to use it you just have to call the selector you created. You can also pass values, services, and another things to it. Example:
app.component.html
QUESTION
I'm trying to export angular custom elements defined in a library L - through the constructor of the AppModule of the library L(customElements.define('my-custom-element', myComponent)).
On importing the library L, my angular application throws exception when using the element,
...ANSWER
Answered 2019-Jun-24 at 04:34You need to import the component into your libraries module and the add it to the declarations and exports section of the module.
Then you need to add that module to the public-api.ts file in the library.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular-elements
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page