# How to access model using controllers

**URL:** <https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867>\
**Category:** Uncategorized\
**Created:** [April 25, 2015, 4:58pm UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867 "2015-04-25T16:58:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CDevs](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@CDevs](https://discuss.emberjs.com/u/CDevs)\
**Post date:** [April 25, 2015, 4:58pm UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/1 "2015-04-25T16:58:30Z")

</div>

How to access model data using controllers. Without using route.

---

<div class="post-metadata">

**Author:** ![od1n](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/od1n/32/10680_2.png) [@od1n](https://discuss.emberjs.com/u/od1n)\
**Post date:** [April 25, 2015, 10:53pm UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/2 "2015-04-25T22:53:57Z")

</div>

Not sure if I got you right, but did you try to call `this.model()` in the controller? Is it a suitable solution?

---

<div class="post-metadata">

**Author:** ![kylecoberly](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylecoberly/32/15828_2.png) [@kylecoberly](https://discuss.emberjs.com/u/kylecoberly)\
**Post date:** [April 25, 2015, 11:08pm UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/3 "2015-04-25T23:08:03Z")

</div>

Models are set on controllers by routes. No route, no model.

If you want to access the store from a controller, you can call `this.store` from its methods. More often than that though, you would inject a service into your controller that does your data access for you. Here’s the [relevant guide](http://guides.emberjs.com/v1.11.0/understanding-ember/dependency-injection-and-service-lookup/).

EDIT: The store is already injected into controllers by default. You should still use services to access data.

---

<div class="post-metadata">

**Author:** ![od1n](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/od1n/32/10680_2.png) [@od1n](https://discuss.emberjs.com/u/od1n)\
**Post date:** [April 26, 2015, 12:13am UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/4 "2015-04-26T00:13:30Z")

</div>

I don’t know for now why do I think so, but I was sure that in some conditions Ember would generate a default route with the `model` function, where it’s trying to obtain the data for the resource of the same name as the route. Is it a fantasy?

---

<div class="post-metadata">

**Author:** ![kylecoberly](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylecoberly/32/15828_2.png) [@kylecoberly](https://discuss.emberjs.com/u/kylecoberly)\
**Post date:** [April 26, 2015, 12:35am UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/5 "2015-04-26T00:35:55Z")

</div>

Routes have a `model` hook that fires when you enter them that is typically used to retrieve data. In the route’s `setupController` hook, this model gets set on the controller’s `model` property. In `ObjectController`s and `ArrayController`s, you can access the model’s properties as if they were properties of the controller. This confused a lot of people, which is why those classes are deprecated.

If you need to look up raw model data from a controller directly you can, but there are few/no good reasons for doing so. If it’s not part of the route’s model, it’s generally better represented as a service or encapsulated in a component.

---

<div class="post-metadata">

**Author:** ![od1n](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/od1n/32/10680_2.png) [@od1n](https://discuss.emberjs.com/u/od1n)\
**Post date:** [April 26, 2015, 1:09am UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/6 "2015-04-26T01:09:30Z")

</div>

In fact I know it all, but nevertheless thanks for your clarification.

---

<div class="post-metadata">

**Author:** ![CDevs](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@CDevs](https://discuss.emberjs.com/u/CDevs)\
**Post date:** [April 26, 2015, 7:55am UTC](https://discuss.emberjs.com/t/how-to-access-model-using-controllers/7867/7 "2015-04-26T07:55:24Z")

</div>

Thanks for the ideas and pointers.
