-
I am writing a table view component, and the natural thing is to create components inside its snippets that naturally bind to the row data object. Also, naturally, the snippet that allows data cell custom content passes the row data object, but I cannot bind to it. So I guess my question is: Am I perhaps missing something? |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Jul 26, 2024
Replies: 1 comment 1 reply
-
As long as you have an object, you can bind to its properties in snippets. <script>
let o1 = $state({ name: 'Tama' });
let o2 = $state({ name: 'Pochi' });
</script>
{#snippet item(data)}
<input bind:value={data.name} />
{/snippet}
{@render item(o1)} {o1.name} <br>
{@render item(o2)} {o2.name} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
webJose
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As long as you have an object, you can bind to its properties in snippets.
REPL