Skip to content

Commit a2b8c6c

Browse files
authored
Merge pull request #177 from Parrryy/teach-passing-actions
Improve explanation of passing actions (#162)
2 parents 9272282 + 2d9147f commit a2b8c6c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

guides/v3.4.0/components/passing-properties-to-a-component.md

+15
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ known as being "bound"). That is, if the value of `componentProperty`
5454
changes in the component, `outerProperty` will be updated to reflect that
5555
change. The reverse is true as well.
5656

57+
In addition to making properties available, actions can be made available
58+
to components. This allows data to flow back up to its parent. You pass actions
59+
like this.
60+
61+
```handlebars {data-filename=app/templates/index.hbs}
62+
{{button-with-confirmation
63+
text="Click here to unsubscribe."
64+
onConfirm=(action "unsubscribe")
65+
}}
66+
```
67+
68+
It is important to note that actions can only be passed from a controller or another
69+
component. They cannot be passed from a route. See [passing an action to the component](../triggering-changes-with-actions/#toc_passing-the-action-to-the-component)
70+
for more details on how to pass actions.
71+
5772
## Positional Params
5873

5974
In addition to passing parameters in by name, you can pass them in by position.

guides/v3.4.0/components/triggering-changes-with-actions.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ to trigger behavior.
192192

193193
That makes it easy to remember how to add an action to a component. It's
194194
like passing an attribute, but you use the `action` helper to pass
195-
a function instead.
195+
a function instead. Actions can only be passed from a controller or
196+
component, they cannot be passed from a route.
196197

197198
Actions in components allow you to decouple an event happening from how it's handled, leading to modular,
198199
more reusable components.

0 commit comments

Comments
 (0)