# How to use application route actions in template/components?

**URL:** https://meta.discourse.org/t/how-to-use-application-route-actions-in-template-components/45217
**Category:** Development
**Created:** [June 3, 2016, 8:03pm UTC](https://meta.discourse.org/t/how-to-use-application-route-actions-in-template-components/45217 "2016-06-03T20:03:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [June 3, 2016, 8:03pm UTC](https://meta.discourse.org/t/how-to-use-application-route-actions-in-template-components/45217/1 "2016-06-03T20:03:23Z")

</div>

👋 In `discourse/app/assets/javascripts/discourse/routes/application.js.es6` there is this action:

> <https://github.com/discourse/discourse/blob/514c3976f05785f487d275af1e96c43533e7a478/app/assets/javascripts/discourse/routes/application.js.es6#L68-82>

`composePrivateMessage` is the action that triggers the composer to write a private message. I am trying to access this action from a component template:

`{{action "composePrivateMessage" user}}`

In the js for this component I am trying something like this:

```
export default Ember.Component.extend({
  tagName: 'div',
  layoutName: 'components/custom-fields-data',
  classNameBindings: ['custom-fields'],
  actions: {
    composePrivateMessage(user) {
      composePrivateMessage();
    }
  },

```

This does not work, which does not come as a surprise. 😒 Do I need to inject the application route or something to have access to the application route’s actions?

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [June 3, 2016, 9:18pm UTC](https://meta.discourse.org/t/how-to-use-application-route-actions-in-template-components/45217/2 "2016-06-03T21:18:35Z")

</div>

This was more of an Ember questions than a Discourse question. Nonetheless, I figured it out.

Firstly, send the action I wanted from `discourse/app/assets/javascripts/discourse/routes/application.js.es6` to the component:

```plaintext
{{my-component-name myAction="composePrivateMessage" user=model}}

```

Next, in the component’s JS file, create the action:

```plaintext
...
actions: {
  myAction(user) {
    this.sendAction('myAction');
    }
  }
...

```

Lastly, in the component `my-component-name` call the action and make the magic happen:

```plaintext
{{action 'myAction' user}}

```

🎤 💧
