I'm look into Angular Elements and thinking of generate our Angular Components into Angular Elements to make it possible to be used outside Angular applications.
Let's say I got a Angular 4 app which imports two different Angular Elements (built in Angular 7) and render them on the same page and I instantiate a service in my Angular 4 component. That service contains data that I want to pass into my Angular Elements, since web components only accepts strings as attributes (inputs), is there any good way for sharing data between/pass the instance of the service into the Angular Elements?
There are five ways to share data between components: Parent to child component. Child to parent component. Sharing data between sibling components.
When we build components in an application, we maybe need to share or send data from parent to child or without a direct connection. Angular provides different these ways to communicate components: Using Input() and Output() decorators. Using Viewchild decorator.
According to the latests talks on angular elements you will be able to pass in an injector when creating the element.
This shared injector will then act as the bridge between the different elements.
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