-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor Html WebComponents make binding/setting Array/Object Properties easier #27654
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
Comments
@MichaelPeter thanks for contacting us. So if I understood correctly you want a way to pass in objects/parameters from a Blazor component to a JS web component? One quick thing that comes to my mind is that there is no straighforward way to deal with this. I'm not sure what the correct semantics here are, for example, should those objects be serialized or "passed by reference". |
Thanks for contacting us. |
Not just passing but also binding. I think they should be passed as object, beeing passed as json should only be only done if defined explicitly. But for example the lit element framework supports writing the property as json in html, as far as I know this is not web component standard. But don't Nail me down on that yet. |
I don't think that, in general, it's possible for something external to the web component to do 2-way binding to one of its JS properties, because there's no standard way to receive notification that one of its JS properties has changed. If there is some standard mechanism I'm missing, please provide details. Thanks! |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. See our Issue Management Policies for more information. |
Hello Mr. Sanderson, thank you for your reply hmmm, that is true there is no standard way to react on changes. Only Proprietary solutions (Notify on Polymer) and no onproperty changed. I am not that good in javascript but overriding As minmal solution would it be possible for example to add to
Think these would make building Blazor wrappers arround WebComponents much easier. Or is there something like that already? Then I could write:
And Custom event listener could notify about property changes. Thank you for your time Greetings Michael |
We do already have a backlog item for supporting getters/setters in JS interop: #25756 Seems like this issue is covered (as much as is possible) then, so I'll mark it as closed now. |
Hello AspNetCore Team,
it is possible to define for Html Web Components complex objects or arrays as parameters.
Like if I want to pass a list of objects as table content or a list of links in a web component.
Here my sample component:
Now currently if I want to set this property I need the following code:
Index.razor:
Javascript:
How it could be done differently:
Could this be improved?
I build a repository with differnet html web component issues, there are also other issues in there :
https://github.com/MichaelPeter/BlazorWebComponentTestApp
importaint are
https://github.com/MichaelPeter/BlazorWebComponentTestApp/blob/master/Pages/Index.razor
and
https://github.com/MichaelPeter/BlazorWebComponentTestApp/blob/master/wwwroot/scripts/TestWebComponents.js
Related:
#27070
#27651
The text was updated successfully, but these errors were encountered: