# Send() undefined for nested routes

**URL:** <https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057>\
**Category:** Questions\
**Created:** [January 18, 2019, 6:41am UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057 "2019-01-18T06:41:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimParsons](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@JimParsons](https://discuss.emberjs.com/u/JimParsons)\
**Post date:** [January 18, 2019, 6:41am UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057/1 "2019-01-18T06:41:12Z")

</div>

I’m trying access the action from the parent controller in the child controller. The following error occurs : Uncaught TypeError: Cannot read property ‘send’ of undefined. How to use the parent controller’s action in child controller ?

Parent Hbs :

 ![50%20PM](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/3X/1/8/180876410f09be4643ffa357cbf330af30692c53.png)Parent Controller : ![28%20PM](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/3X/1/b/1b1a58199fe1206cfa2af4bab3af8431133b327b.png)Child Hbs : ![09%20PM](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/3X/3/8/385f28cae4107e7f147689d6f0f4401e61cde855.png)Child controller: ![05%20PM](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/3X/c/f/cf310fcb80ba9dd8681a97761e154c520dbd1a7f.png)

---

<div class="post-metadata">

**Author:** ![CezaryH](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/cezaryh/32/13527_2.png) [@CezaryH](https://discuss.emberjs.com/u/CezaryH)\
**Post date:** [January 18, 2019, 9:39am UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057/2 "2019-01-18T09:39:00Z")

</div>

Hey, Best idea would be to extract message action to mixin and extend both controllers with it.

---

<div class="post-metadata">

**Author:** ![JimParsons](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@JimParsons](https://discuss.emberjs.com/u/JimParsons)\
**Post date:** [January 18, 2019, 10:21am UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057/3 "2019-01-18T10:21:58Z")

</div>

Thanks for your reply! But I’m pretty new to ember and I have not used mixins here.

---

<div class="post-metadata">

**Author:** ![CezaryH](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/cezaryh/32/13527_2.png) [@CezaryH](https://discuss.emberjs.com/u/CezaryH)\
**Post date:** [January 18, 2019, 1:47pm UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057/4 "2019-01-18T13:47:06Z")

</div>

No problem, you can learn about mixins here [Mixin - 4.6 - Ember API Documentation](https://www.emberjs.com/api/ember/release/classes/Mixin)

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [January 18, 2019, 3:34pm UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057/5 "2019-01-18T15:34:56Z")

</div>

So I believe the `needs` syntax is no longer a thing, and if it was you’d want the “needs” at the root level of the controller anyway, not in the actions hash. If you want to do something like this in modern Ember I believe you can do the following:

```auto
import Controller, {
  inject as controller
} from '@ember/controller';

export default Controller.extend({
  parent: controller(),

  actions: {
    message() {
      this.get('parent').send('message');
    }
  }
});

```

---

<div class="post-metadata">

**Author:** ![JimParsons](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@JimParsons](https://discuss.emberjs.com/u/JimParsons)\
**Post date:** [January 21, 2019, 4:56am UTC](https://discuss.emberjs.com/t/send-undefined-for-nested-routes/16057/6 "2019-01-21T04:56:14Z")

</div>

@dknutsen Okay, got it. Thank you.
