Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve explanation of passing actions (#162) #177

Merged
merged 3 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions guides/v3.4.0/components/passing-properties-to-a-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ known as being "bound"). That is, if the value of `componentProperty`
changes in the component, `outerProperty` will be updated to reflect that
change. The reverse is true as well.

In addition to making properties available, actions can be made available
to components. This allows data to flow back up to its parent. You pass actions
like this.

```handlebars {data-filename=app/templates/index.hbs}
{{button-with-confirmation
text="Click here to unsubscribe."
onConfirm=(action "unsubscribe")
}}
```

It is important to note that actions can only be passed from a controller or another
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)
for more details on how to pass actions.

## Positional Params

In addition to passing parameters in by name, you can pass them in by position.
Expand Down
3 changes: 2 additions & 1 deletion guides/v3.4.0/components/triggering-changes-with-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ to trigger behavior.

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

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