# Apply Filter to Models

**URL:** <https://discuss.emberjs.com/t/apply-filter-to-models/8065>\
**Category:** Uncategorized\
**Created:** [May 23, 2015, 2:45pm UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065 "2015-05-23T14:45:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mistic](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mistic](https://discuss.emberjs.com/u/mistic)\
**Post date:** [May 23, 2015, 2:45pm UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065/1 "2015-05-23T14:45:50Z")

</div>

Hello,

I’m developing my first EmberJS and at the moment i have a doubt.

I have at the moment the following problem:

-I have one ArrayController PersonsController that generate a list of persons in a template -I have one ObjectController PersonController that generate the info about person

In the route persons/person/id i’m showing the persons list and the info about the selected person.

At the momment i’m trying to apply a filter to the ArrayController model and i’m filtering the list of persons but this filter has to filter to inside the objectController. How can i filter in the two controller with same filter? The model of object controller isn’t updating and i dont know how to access the objectController from ArrayController to manually filter the model.

Regards

---

<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:** [May 23, 2015, 11:59pm UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065/2 "2015-05-23T23:59:54Z")

</div>

For me it seems like you need to move this part

> In the route persons/person/id i’m showing the persons list

to the common /persons route-controller and to add yield there for sub-routes. Does it make sense for you or you need more details?

---

<div class="post-metadata">

**Author:** ![mistic](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mistic](https://discuss.emberjs.com/u/mistic)\
**Post date:** [May 25, 2015, 1:26pm UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065/3 "2015-05-25T13:26:28Z")

</div>

Hello od1n,

Can you explain a bit better your suggestion?

I think that i cannot have the person list and the person info on the same template page if i have to do things in another way, because for every person that i click to view the info i have a different route.

Regards

---

<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:** [May 28, 2015, 9:57am UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065/4 "2015-05-28T09:57:10Z")

</div>

> [@mistic](#):
>
> I think that i cannot have the person list and the person info on the same template page if i have to do things in another way, because for every person that i click to view the info i have a different route.

And you actually don’t need it. Look, you have route `persons` which is including sub-route `index` by default. The next step is to generate sub-route `person`. `persons` and `person` have different controllers, routes (I mean Ember.Route), and templates. So you can obtain the list of persons in the route for `persons`. Then you need to add the `{{yield}}` keyword to the `persons` template and also render there the list of people.

---

<div class="post-metadata">

**Author:** ![mistic](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mistic](https://discuss.emberjs.com/u/mistic)\
**Post date:** [May 29, 2015, 3:30am UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065/5 "2015-05-29T03:30:28Z")

</div>

Hello,

Thanks for the answer. What’s the difference between {{yield}} and {{outlet}}? (im using the outlet)

Regards

---

<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:** [May 29, 2015, 3:59am UTC](https://discuss.emberjs.com/t/apply-filter-to-models/8065/6 "2015-05-29T03:59:45Z")

</div>

Oh, sorry, just used to rails, where `yield` keyword is used. I meant `{{outlet}}` previously.
