Skip to content

Commit

Permalink
Merge pull request #2944 from sveltejs/component-binding-example
Browse files Browse the repository at this point in the history
Fix component binding example
  • Loading branch information
jacwright committed Jun 4, 2019
2 parents a5cdc13 + f65379f commit 04162b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions site/content/docs/02-template-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,12 @@ You can bind to component props using the same mechanism.

Components also support `bind:this`, allowing you to interact with component instances programmatically.

> Note that we can do `{cart.empty}` rather than `{() => cart.empty()}`, since component methods are closures. You don't need to worry about the value of `this` when calling them.
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.
```html
<ShoppingCart bind:this={cart}/>

<button on:click={cart.empty}>
<button on:click={() => cart.empty()}>
Empty shopping cart
</button>
```
Expand Down Expand Up @@ -1325,4 +1325,4 @@ It accepts a comma-separated list of variable names (not arbitrary expressions).
{@debug typeof user === 'object'}
```

The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.
The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.

0 comments on commit 04162b9

Please sign in to comment.