Skip to content

Commit

Permalink
tested the example in sveltejs/svelte#2308 (comment), it works
Browse files Browse the repository at this point in the history
  • Loading branch information
iacore committed Apr 20, 2024
1 parent a2debfa commit 72f33ea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/App.svelte
@@ -1,9 +1,13 @@
<script>
let name = ['existing option'];
</script>

<h1>Refresh to reset</h1>
<h1>{JSON.stringify(name)}</h1>
Try click on these:
<input type="checkbox" value="no" bind:group={name}>
<input type="checkbox" value="yes" bind:group={name}>
{#each menu as flavour}
<Flavour {flavour}/>
{/each}

<script>
import Flavour from "./Flavour.svelte"
let menu = [
'Cookies and cream',
'Mint choc chip',
'Raspberry ripple'
];
</script>
8 changes: 8 additions & 0 deletions src/Flavour.svelte
@@ -0,0 +1,8 @@
<label>
<input type=checkbox bind:group={$flavours} value={flavour}>
{flavour}
</label>
<script>
import { flavours } from "./stores.js"
export let flavour
</script>
5 changes: 5 additions & 0 deletions src/stores.js
@@ -0,0 +1,5 @@
import { writable } from 'svelte/store';

export const flavours = writable([]);

flavours.subscribe(console.log)

0 comments on commit 72f33ea

Please sign in to comment.