-
Notifications
You must be signed in to change notification settings - Fork 24.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular Elements doesn't bind existing property values to component inputs #30848
Comments
Just to add additional context, one of the reasons why this bug is so frustrating is that the only work-around (if you can even call it that) that works with AoT is to iterate through the property names and try to reconcile the values from the injected element. This is obviously not maintainable. At least if Following this, once this bug is fixed it should be ensured that |
+1 My use case is that I have an Angular Element nested in a JQuery application and I would like to be able to pass complex data from my JQuery app to my custom element. It seems there are several ways of doing this, but the most appropriate and easiest to implement is to pass the object through a property. Currently the Angular Element code does not acknowledge any changes I make to it's corresponding custom element's property values, so I have to use the much less elegant solution of stringifying my object, passing the stringified data through an attribute, then in the Angular Element parsing the string to rebuild my object. This leaves messy HTML (if you view it through the developer tools) and adds the unnecessary overhead of having to stringify/parse my data. |
Your issue sounds like maybe a different thing. You really shouldn't have a problem with jQuery, you should be able to set the property with
I've tried the above and it works. |
Hmmm... I'll look into making a minimum reproduction of my issue. My current implementation is
In my Angular Element no change detection fires in either case and 'propertyToSet' never gets set. Though if I run |
I made a minimum reproduction here #31055, please check it out if you get the chance. |
FWIW I was able to kind of work around this and #30834 with a custom input decorator and component base class. It's a little verbose but I wasn't able to come up with an easier way (that's AoT compatible): https://stackblitz.com/edit/angular-elements-test-input-bindings-decorator This will also fire |
wow... I found my bug. I was trying to set the property before Angular finished bootstrapping. @antch Thank you so much for your help. It was reading your stackblitz code that made me realize my mistake (index.html line 8 to be specific). |
Thank you very much for the fix @robwormald. Do you know if there's another issue for |
@robwormald Sorry to be... persistent... but do you have an update on this? It seemed really close and then no activity for 10 months... |
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416
…ent (#36114) Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes #30848 Closes #31416 PR Close #36114
…ent (angular#36114) Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416 PR Close angular#36114
…ent (angular#36114) Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416 PR Close angular#36114
…ent (#36114) (#37226) Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes #30848 Closes #31416 PR Close #36114 PR Close #37226
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…ent (angular#36114) Previously, if an element started out as a regular `HTMLElement` (not a Custom Element) and was later upgraded to a Custom Element, any properties corresponding to component inputs that were set on the element before upgrading it would not be captured correctly and thus not reflected on the instantiated component. This commit fixes it by ensuring that such properties are captured correctly. Jira issue: [FW-2006](https://angular-team.atlassian.net/browse/FW-2006) Fixes angular#30848 Closes angular#31416 PR Close angular#36114
🐞 bug report
Affected Package
The issue is caused by package @angular/elements
Is this a regression?
Unsure.
Description
If a DOM element has existing properties prior to being loaded/initialized by Angular Elements, they are not bound to component inputs.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-elements-test-existing-bindings
🔥 Exception or Error
No error occurs, properties are not bound.
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: