0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

Tutorial: Description fix - each block bindings (#5974)

The chapter highlights event binding in `each` block which is missing within the snippet. Thus it seems reasonable to include it within the description snippet block.
This commit is contained in:
Kai 2021-05-29 19:56:17 +02:00 committed by GitHub
parent ad29604d6b
commit 1a1f36edcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,15 +5,17 @@ title: Each block bindings
You can even bind to properties inside an `each` block.
```html
<input
type=checkbox
bind:checked={todo.done}
>
{#each todos as todo}
<input
type=checkbox
bind:checked={todo.done}
>
<input
placeholder="What needs to be done?"
bind:value={todo.text}
>
<input
placeholder="What needs to be done?"
bind:value={todo.text}
>
{/each}
```
> Note that interacting with these `<input>` elements will mutate the array. If you prefer to work with immutable data, you should avoid these bindings and use event handlers instead.
> Note that interacting with these `<input>` elements will mutate the array. If you prefer to work with immutable data, you should avoid these bindings and use event handlers instead.